Hi, this question is related to the following ticket: https://toolset.com/forums/topic/display-related-post-type-2/
I managed to list all the Artworks of an Artist in the Artist single page template. However, I am unable to display all the related Artworks of an Artist in the Artwork single page template. How should I go about doing this? I am using Blocks not Classic.
Hi,
Thank you for contacting us and I'd be happy to assist.
To achieve this, you can follow these steps:
1. Please create a new content template and name it something like "CT for showing related Artworks".
( WP Admin -> Toolset -> Content Templates )
Note: You don't have to assign this content template to any post or page.
2. In this new content template, you can add a "View" block and set it to show the "Artworks" posts.
3. At this point, this newly created view will be showing all the "Artworks" posts. To limit it to only to the posts related to the current "Artist", you'll need a post-relationship "Query Filter" with "The current post in the loop" option, as shown in the attached screenshot.
4. The last step would be to include the shortcode for this newly created content template inside the Artwork single page template, through a "Fields and Text" block.
[wpv-post-body view_template="CT for showing related Artworks" item="@artist-artwork.parent"]
Note: You'll replace "CT for showing related Artworks" with the actual name of the content template created in step 1. Also "artist-artwork" will need to be changed to match the actual relationship slug used on your website.
The item="@artist-artwork.parent" part in the shortcode changes the scope of the content template from the current "Artwork" post to its related "Artist" post.
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/ )
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Hi Waqar, thanks so much for your help, I truly appreciate it. I can now create the related posts. The solution you provide me works like a charm!