I have a cpt called Special Reports and another CPT called special article.
I have a one to many relationship betweeen Special Reports and special article, whereby one special report can have unlimited special articles:
-Special Report
-- Special Article
I am trying to create a view where on the single special article, it shows all the special articles that are related to the parent special report ( so that on the side of a single special article I can show all the other special articles belonging to the same special report)
So far all the filtering options render "No results found"
Hi Adrian,
Thank you for contacting us and I'd be happy to assist.
To achieve this, you can follow these steps:
1. First, you'll need the ID of the "Special Report" post that is attached to the current "Special Article" post.
You can use "wpv-post-id" shortcode ( ref: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-id ) with "item" attribute ( ref: https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/ ), like this:
[wpv-post-id item="@{relationship-slug}.parent"]
Note: you'll replace "{relationship-slug}" with the actual slug of this relationship.
2. Next, you'll need a post view to show the "Special Article" posts, but it will have a query filter that will make it bring only those posts which are related to the "Special Report" post, whose ID is passed in the view's shortcode attribute, similar to what is shown in your screenshot.
( ref: https://toolset.com/documentation/user-guides/passing-arguments-to-views/ )
On your single post pages for special articles, you can call this new view like this:
[wpv-view name="slug-of-the-view" wpvrelatedto="[wpv-post-id item='@{relationship-slug}.parent']"]
Note: replace "slug-of-the-view" with the actual slug of your view.
You can check the option "Don't include current page in query result" in the view's "Query Options", to make sure that the current special articles post is not included in the results.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar