Skip Navigation

[Resolved] Listing children of pages does not work, if children are custom posts

This support ticket is created 6 years, 9 months 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 10 replies, has 3 voices.

Last updated by gerhardS 6 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#630619

I am trying to:

display a list of pages and custom posts on a page, which is a parent to these pages and custom posts.
I created a view with a content selection of "Page" and "Post Series" (my custom post type) and a Query Filter, which selects all the children of the current page.

The pages and the post series are hierarchical and the parent is set to "Islands". in the custom post type Pages are set as parents and Posts are set as children. In the "Fuerteventura" custom post the parent page is set to be "Islands", which is a page.

Link to a page where the issue can be seen:

hidden link

I expected to see:

All the custom posts and pages should be shown in the sidebar (which is not the page sidebar, but a column in a toolset layout). Each entry consists of a featured image and the Title of the page or custom post.

Instead, I got:

Only the child pages are shown (Rügen). There is also a child custom post about Fuerteventura, which has this page as a parent, but it is not shown.

#630842

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - with the link you shared: hidden link

Do you mean that you wanted to show both child pages or both parent and child posts?

Can you please show me how you set the parent for pages or posts? Maybe a screenshot will help to understand how you set the parent.

#631216
screenshot.20.jpg
screenshot.19.jpg
screenshot.18.jpg

Hello,

I attached screenshots of the Post Relationship in the Definition of the custom type Post Series and the end of the configuration of the Post Series Instance "Fuerteventura", which shows, that page "Islands" is set as parent.

Then there is the view "List Pages" with the query filter (screenshot20) and the loop:

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop wrap="1" pad="true">
[wpv-item index=1]
<div class="row ">
<div class="col-sm-12">
[wpv-post-body view_template="page-sidebar"]
</div>
</div>
[wpv-item index=pad]
<div class="col-sm-12"></div>
[wpv-item index=pad-last]
<div class="col-sm-12"></div>
</div>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

And here is the content template "Page Sidebar":

[wpv-post-featured-image size="featured-sidebar"]
<h5>[wpv-post-link]</h5>

This works for the only child page "Rügen" of page "Islands", but the child Post Series "Fuerteventura" is not displayed.

#631495

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - you are using wrong filter. You should delete the current query filter and try to add the "post relationship filter" when you click on button "Add a filter" and from drop-down select box - select the "Post relationship filter" and add it and then select the option "Post where this View is shown" and save the filter or chose your desired option that matches your requirement.

See following screenshot:
=> hidden link

#631806

Yes, this works and I have tried it before, but it only shows the custom posts, while the other filter only shows the pages. What I need is both. I have created 2 views now and everything displays, but it is not sorted (I do not want to make any distinction between the pages and the custom posts in the list, so it should be just one sorted list).

It would work, if I could use both filters with OR, but the filters are combined with AND. So I do not get any result, if I use both filters in one view. Can you think of any solution for this?

#631902

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - I think I've solution for that but I need to check first - I would like to know how you are adding both filters?

Could you please setup both filters and send me access details and tell me which view you are using.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually 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.

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. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#632378

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - I checked the view's configuration but I need FTP access in order to check if I can able to make any changes to filters you added.

Please share FTP details. I've not made any changes to your site.

#680560

Sorry for my late reply, but I am travelling.

I tried to change the FTP password or create a temporary extra account, but it is not possible and I do not want to mess with it too much. So I cannot give you FTP access.

Also I would like to change this to an enhancement request: As there is support to set up a hierarchy of pages and custom posts, there should also be a possibility to use this consistently within toolset without having to do any PHP hacks.

What I would expect is a single filter, that works on page and custom post hierarchies in the same way, so I can create a single view displaying all children of a specific page, regardless of the type of the child (page or custom post). They all have the same page as a parent, so it should be able to display them together in any chosen sort order.

#683228

Hello,

Minesh isn't available currently.

I have tried the credentials you provided above:
https://toolset.com/forums/topic/listing-children-of-pages-does-not-work-if-children-are-custom-posts/#post-632048
I get this error:
Access Denied - Sucuri Website Firewall
So I can not check it in your website, and you will get answer from Minesh in tomorrow.

#690215

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What I would expect is a single filter, that works on page and custom post hierarchies in the same way, so I can create a single view displaying all children of a specific page, regardless of the type of the child (page or custom post). They all have the same page as a parent, so it should be able to display them together in any chosen sort order.
==> Well - this is not actually possible with single filter as there is no automatic way to identify that you are queering page or posts or both. So there is two possibilities as I explain you before that either you should have different view for your both post type (page and post) or you need to add filter using view's hook where we can do amendments with passed arguments on fly.

#712163

I do not really understand, why you can do it with PHP and not with Toolset, which would use the same programming language. So it is just a feature, which is currently not implemented and the current solution is not very consistent (custom posts and pages can all be children of pages and so it should be possible to query all children of a certain page, whatever type they are). Having two different filters for the same thing is not logical and not a good way to do it anyway.

Let's close this and I will make an extra feature/enhancement request for this.