Skip Navigation

[Résolu] View filters by parent before displaying child – needs to only show published

This support ticket is created Il y a 7 années et 5 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 13 réponses, has 2 voix.

Last updated by Luo Yang Il y a 7 années et 5 mois.

Assisted by: Luo Yang.

Auteur
Publications
#453226

I am trying to: display child posts of a filtered parent

I visited this URL: support

I expected to see: a solution

Instead, I got: none

i have custom post types (parent is Artist) (child is Performance)
I've created a bunch of views throughout my site
The first VIEW filters Artist (i.e. by its taxonomy term), then in the second VIEW it displays the child post (performance)

This all works fine

However, There are many times when there will be published parents (Artists), but their children (Performances) won't exist yet or be published ((yet)).

In testing this, it looks like if the first view does its filter but there is no child post, then it just stops running and then the whole views in views turns out nothing.

I can provide you with access to the site to see.

thank you.

#453314

Dear jeffrey,

I need details to duplicate same problem, I assume we are talking about this:
Parent post type "Artist"
-- Child post type "Performance"

A custom taxonomy, for example "artist-tax", which is registered to parent post type "Artist".

Two views:
1) The first VIEW lists Artist posts, and filter by taxonomy "artist-tax",
2) Child view, lists the child performance post,
How do you setup the filters in the child view? how do you put it into the content?
What do yo mean this:
it just stops running and then the whole views in views turns out nothing.

Is it output blank page?

Before we do further debug, please try below first:
1) deactivate other plugins and switch to wordpress default theme, and test again
2) Enable PHP debug mode, copy and paste the debug logs here
PHP Debugging
In case you think that Types or Views are doing something wrong (what we call a bug), you should enable PHP error logging. Again, edit your wp-config.php file and add the following:

ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
This will produce a file called ‘error_log.txt’ in your WordPress root directory. Make sure that the web server can create and write this file. If it cannot, use an FTP program to create the file and make it writable to Apache (normally, user www-data).
https://toolset.com/documentation/user-guides/debugging-types-and-views/

#455171

Hi Luo,

1) The first VIEW lists Artist posts, and filter by taxonomy "artist-tax",
yes, this is correct

2) Child view, lists the child performance post,
How do you setup the filters in the child view? how do you put it into the content?

the child view has a filter of 'select posts that are children of the current post in the loop'

What do yo mean this:
it just stops running and then the whole views in views turns out nothing.
Is it output blank page?

yes, the output for that view will be blank.

I do not think this is a bug at all. I think I need to add in some sort of filter to the first view that says get Artists posts IF they have child posts that are published. I just have no idea how to do that.

I can provide you with login to a staging environment and show you the exact problem if you send me a private message.

Thanks very much,
Jeff

#455193

Thanks for the details, there isn't such a feature within Views that can do this:
filter to the first view that says get Artists posts IF they have child posts that are published

I suggest try this:
In the child view (second view), section "Loop Output Editor", within shortcodes[wpv-items-found] ... [/wpv-items-found], display the parent Artists posts information, see our document:
Displaying Fields of Parent Pages
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/

#455194

Hi,

I already know how to display parent information. I actually do this. But I don't understand what that has to do with this problem.

If you send me a private message I can show you the problem. I'd have to think there's a solution, otherwise this will be a big problem for me.

Jeff

#455205

OK, please fill below private detail box with credentials of your website, also point out the problem page URL and view URL, thanks

#455408

i didn't get the 'reply via secure form' option

#455605

I just enabled the "private detail box", please try again.
Fill it with credentials of your website, also point out the problem page URL and view URL, thanks

#455640

Thanks for the details, I am checking in your website, will feedback if there is anything found

#455650
1021.JPG

Are we talking about this problem:

since there isn't child posts under the "pop", you do not want display the line of "Pop", see screenshot: 1201.JPG

If not, please describe more details for the question:
I think because it begins looking for artists, tagged with pop, then doesn't find a performance... and then stops.

#455776

I think you attached the wrong screenshot, I dont know what that is.

And no, that's not the problem.

Here's how it is setup:

There is a parent post (type: Artist), i.e. 'Adele'
with a child post (type: Performance), i.e. 'Adele - Someone Like You'
The parent posts (Artists) have a taxonomy (Genre), i.e. 'Adele' is tagged with 'Pop'

To display this in the website, there is a parent VIEW (Artists filtered by Genre: Pop), with a child VIEW (Performances filtered by 'children of current post in loop'. This displays Performances that have Artists tagged with Pop.

The PROBLEM occurs when:

A new post (Artist) is created, i.e. 'Guster' tagged with (Genre:Pop)
BUT, does not have a *published* child post (Performance), yet.

The VIEW within VIEWS doesn't display anything at all, but it should. Because, there are lots of (Artists filtered by Genre:Pop) with *published* (Performances).

I think what is happening is it runs the parent view (i.e. it finds Artists filtered by Genre: Pop), so in this example it identifies 'Guster'... then, it runs the child view but does not find any child posts (Performances) that are *published*... SO, it shows nothing, at all. Not even 'Adele - Someone Like You', when we know that it is published and has a Parent (Artists) tagged with (Genre: Pop).

I think, there's a simple solution where the Views within views, just needs either a filter or a condition that says only consider posts that have the status published.

Please let me know if you need more detail.

Jeff

#455995
1203.JPG
1202.JPG

Sorry for the screenshot, here is what I found in your website, please correct me if there is anything missing:

1) In the home page,
hidden link
there is a section "Pop", which does have any result, see screenshot 1202.JPG
I assume we are talking about this section "Pop"

2) The section is outputted by a nested view:
Parent view "Home - Top - Random Pop",
hidden link
-- Child view "Home - Bottom - Random"
hidden link

3) A new post (Artist) is created, i.e. 'Guster' tagged with (Genre:Pop)
I assume we are talking about this post:
hidden link
There isn't any child "Performance" posts in it

4) The VIEW within VIEWS doesn't display anything at all, but it should. Because, there are lots of (Artists filtered by Genre:Pop) with *published* (Performances).
What should it display?
I can not see any (Artists filtered by Genre:Pop) with *published* (Performances).
I tested this:
a) Edit the Performance post "Fleet Foxes"
hidden link
Setup it's parent post as "Guster",
b) Refresh the front page, see screenshot 1203.JPG
The "Guster" display as expected.
So which one is the (Artists filtered by Genre:Pop) with *published* (Performances), could you point out the links for them?

#456111

I think you were able to get the Guster example to display because it was based on date, so since you modified it, it would be the newest one. You can see this if you change the top view to 'sort by date', like I just did for Rock. When it's on sort by random, it seems to be ok.

But even though you were able to get the Guster one to work, you can still see the problem because the rest of the row is empty

There are almost 200 artists tagged with Pop
wp-admin/edit.php?genre=pop&post_type=artist
many of them have performances

For example, Artists Adele is tagged with Pop and has a performance
/video/adele-someone-like-you/

But it and all the other performances with an artist tagged with Pop doesn't show up in that view
or on the archive page
/genre/pop/

If you open the debug you can see that it is executing the top view, and finding artists
but then since they don't have published performances, it shows nothing

I think this is all because of the 'sort by date'.
It makes sense, the view is supposed to find the most recent artist, then find its performances. if it doesn't have any performances, it will leave a blank space.

i just want to somehow make the views-in-views a little bit smarter, to add a condition that says ignore this 'views-in'views' search if the child post isn't published. and then that way, it would only consider views-in-views where the artist and performance are both published.

#456700
1213.JPG

Thanks for the details, there might be some cache problem in your website, I tried these:
1) Create a child "Performance" post "video 3103":
/wp-admin/edit.php?post_status=trash&post_type=video
and move it into trash,

2) Then refresh the home page again
Seems it works fine now, see screenshot 1213.jpg

Please test again, check it is fixed or not. thanks

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.