Tell us what you are trying to do?
I have two post types with a one (parent) to many (child) relationship. On each child page I need to output a list of all the child pages belonging to the parent of the current child page. Every child page needs this list so I need to loop through them all in a view.
Is there any documentation that you are following?
I found some relevant information on this page: https://toolset.com/documentation/user-guides/views/filtering-views-query-by-post-parent/ but the information is not complete enough to understand exactly how I set it up.
Is there a similar example that we can see?
What is the link to your site? dev.rusoffagency.com
Hello,
I assume we are talking about Toolset one-to-many relationship, if it is please try these:
1) Create a content template "parent-post-information", display below post view "related child posts view":
- Query "child" posts
- Filter by:
Select posts in a {YOUR-ONE-TO-MANY} relationship that are related to the Post where this View is shown.
- In view's loop, display the the child post information
2) In the single child post, display above content template shortcode with item attribute, for example:
[wpv-post-body view_template=""parent-post-information"" item="@{YOUR-ONE-TO-MANY-SLUG}.parent"]
More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
If your current post is in a relationship acting as child post, you can use the value of @{relationship-slug}.parent to obtain data from the related parent.
I'm only getting the current post title in my list. There should be 4 titles as there are 4 Additional Book Info posts related to the parent book.
Here is my code:
At the top of the Loop in the View:
[wpv-post-body view_template="parent-post-information" item="@fiction_book-info.parent"]
[wpv-post-body view_template="parent-post-information" item="@non_fiction_book-info.parent"]
The loop:
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-post-link]
</wpv-loop>
<!-- wpv-loop-end -->
My Template:
[wpv-conditional if="( '[wpv-attribute]' eq '@fiction_book-info.parent' )"][wpv-post-link item="@fiction_book-info.child" class="sep-book"][/wpv-conditional]
[wpv-conditional if="( '[wpv-attribute]' eq '@non_fiction_book-info.parent' )"][wpv-post-link item="@non_fiction_book-info.child" class="sep-book"][/wpv-conditional]
Relationship:
Fiction Book > Additional Book Info (relationship slug is fiction_book-info
Non Fiction Book > Additional Book Info (relationship slug is non_fiction_book-info
Both relationships are one to many
To avoid wrong settings, I suggest you try different content templates for each post type relationship, so you don't need to use [wpv-conditional] shortcode in those content templates.
I’ve gone a different direction by following the instructions on this post: https://toolset.com/documentation/legacy-features/views-plugin/displaying-related-child-posts/#using-views-only
I also am just trying to start with just one post type instead of using conditionals. I was able to get all the child pages to show up in the list. If I am not logged in to WordPress, the list looks fine but there is other information displaying above. If I am logged in and viewing the front end, I see multiple infinite loop errors in red.
Please share a test site with same problem, fill below private message box with login details, also point out the problem page URLs, I need to test and debug it in a live website, thanks
My issue is resolved now. Thank you!