Skip Navigation

[Closed] 'Select posts that are children of' not showing posts

This support ticket is created 8 years, 1 month ago. 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Beda 8 years, 1 month ago.

Assisted by: Beda.

Author
Posts
#371697

I am trying to:

Display child posts using 'Select posts that are children of'

My Posts CPT is called 'Tips' which are children of 'Racecourses' and 'MBR Service'. 'MBR Service' has 3 parent posts:

- MBR Live
- Premium Bets
- Platinum Membership

There are over 3000 tip posts of which most of them are children of 'Platinum Membership'. In the View if I select posts that are children of 'MBR Live' or 'Premium Bets' everything works well. If I select posts that are children of 'Platinum Membership' no posts are found.

I have extensively troubleshooted this from every angle including:

- recreating the parent and using SQL to change to new parent by updating '_wpcf_belongs_mbr-service_id' field

- I have made sure 'tips' has been cleaned by removing all data and re-importing use CSV (I had some old unwanted postmeta anyway which allowed me to clear everything)

I now have over 3000 tips and when I specifically set the parent to filter by children of 'Platinum Membership' nothing works, but exactly the same query using a different parent works perfectly.

I have a View and demo page setup if someone would like access to my site?

#371744

I must recap a bit here, so to confirm I understand the structure.

1. Custom Post Type (CPT) "Tips" is child to:
- CPT "MBR Services"
- CPT "Racecourses"

2. CPT "MBR Services" is child to:
- CPT "MBR Live"
- CPT "Premium Bets"
- CPT "Platinum Membership"

3. You want to display in a View, Posts of CPT "Tips", that are child of the CPT "Platinum Membership"

Since "Tips" is not set as a Child of that Post Type, there is not chance Views will return some posts.

What you will do in this case, is to create 2 Views, or query the correct Parent Post Type.

1. You can create a View and display "MBR Services" that are child of "Platinum Membership"
2. Then, another View, inserted in this first View, is returning "Tips" that are Child of the post set by the parent View.
3. You query directly the correct parent of Tips, or return the direct child of "Platinum Membership"

More info in this can also be found here:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/
https://toolset.com/documentation/user-guides/displaying-related-child-posts/

Please let me know if you have further questions regarding the issue mentioned in this Thread

Thank you for your patience.

#371754

Thanks for the reply...

No - the structure you have is not correct. Platinum Membership, MBR Live and Premium Bets are not CPT's they are parent posts (MBR Service). There are only 3 MBR Service posts. If either MBR Live or Premium Bet posts are set as parent then the view shows the child tips as expected. When the tip parent is set to Platinum Membership the View is empty.

The only setting I am changing in View is the name of the parent post but it only works for 2 out of the 3 parents!

#371795

OK, then this looks as the below:

1. Custom Post Type (CPT) "Tips" is child to:
- CPT "MBR Services" >> has 3 posts
- CPT "Racecourses" >> is irrelevant to this Thread

2. You have set ALL "Tips" to be child to either Platinum Membership, MBR Live and Premium Bets which are all CPT "MBR Services"

3. If the hidden custom field in the Child Post "Tip" is correctly populated with the parent Post ID, and the meta_key of this field is correct, Views will react as follows:

- Query Filter in a View for "Tips" > Select posts that are children of... [MBR Services] > Platinum Membership
- Loop as example is the Post Title
==> It will output all "Tips" that are child to the above Post in the given Post Type.

This works 100%.

I see that you edited via SQL the DDBB relationship and that might have introduced some issues, or the relationship was not saved properly initially.

To debug the issue I suggest this:

1. Head to Views > Settings > Hidden Custom Fields
- find the hidden Custom field that must look as this:

_wpcf_belongs_parent-post-type-slug_id

- check the box next to it and save
- go and create a new view, query the Post Type "Tips" with no filters or searches or restrictions.
- in the View Loop output this:

<li>[wpv-post-title] is child to: ID - [wpv-post-field name='_wpcf_belongs_parent-post-type-slug_id'] Post Title - [wpv-post-title id='[wpv-post-field name='_wpcf_belongs_parent-post-type-slug_id']']</li>

If the above code dos not work, please remove all the part of "Post title - and subsequent ShortCode"

This should now output a List of "Tips", with the corresponding parent Post ID next to it.

If you can not find the Platinum Membership Post ID, it means its' not saved, the field is not named correctly or another DDBB issue exists.

Please let me know the results.

Thank you for your patience.

#371848

Hi, I had checked and have done all this previously, I even created a new Platinum Membership post and updated the parent id (_wpcf_belongs_mbr-service_id to new ID). This works initially, but at some point when I update all 3000 records with new parent the same issue occurs.

I can only think there is a post somewhere that is causing no records to be returned or that the query fails for some reason?

#372037

According to this:
"This works initially, but at some point when I update all 3000 records with new parent the same issue occurs."

Then it means either some Query breaks due to too many requests, or the fields are not updated fine and properly.

1. How do you update the 3000 Posts?

2. Can you locate the Post where it begins to break?

3. Can you enable the Views Debug mode in Views > Settings > Development and check the Query, that will pop up in the front end?
https://toolset.com/documentation/user-guides/debugging-types-and-views/

This is certainly a issue with either a overload of the query (which definitely should not happen) or a issue with a specific query that you use to update the posts, if you use to do that directly in the DDBB.

Please could you provide me the additional Infos?

Thank you for your patience.

#372366

1. Because I could't understand why the view wasn't generating the required output I thought it must be something to do with the posts. So I used a view to dump all data into a table which I copied and created a CSV file. I then deleted all the original posts and postmeta (using WordPress bulk delete plugin). I then re-imported the 3000 posts using a WordPress CSV important plugin (after testing extensively that all fields were mapped)

2. No, I cannot locate the post where things start to break as I get all if I don't filter by the parent post type in question, or no posts returned if I do

3. I enabled the debugging and I looked through everything but I couldn't see anything that is obvious to me. However I am not great with SQL queries

If I provided you with access would you be able to take a look? You can email me for details? Thanks

#372449

I would need to request temporary access (WP-Admin and FTP) to your site
- preferably to a test site where the problem has been replicated if possible -
in order to be of better help and check if some configurations might need to be changed

Your next answer will be private which means only you and I have access to it.

❌ Please backup your database and website ❌

✙ I would, if possible, need access to a site where only a minimal set of Plugins and a default theme is active.
This to avoid eventual compatibility issues with other software.

✙ I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site.
This is also a reason the backup is really important

✙ Please add the Links to:

- The Views Edit Screen

- The Page/Post where you insert the View

- The corresponding Front End Page/Screen

I will need to do extensive checks and eventual Views Loop Code changes and even new views.

Please make sure you grant me access to a fast as possible site with as less as possible other plugins, we don't want to debug a issue eventually coming from somewhere else, right?

Please also acknowledge that I am off tomorrow, Saturday and Sunday

I will ask a colleague to keep an eye on this thread but I can not promise they will have time to perform all the required steps.

I apologize this inconvenience.

Thank you for your patience and cooperation.

The topic ‘[Closed] 'Select posts that are children of' not showing posts’ is closed to new replies.