I am trying to display the post names of siblings in a series of post types on their own sidebars. I thought I had it solved, but it's telling me no items found.
Effectively, I would like to post a list of entries for a post type related to a parent.
e.g: All entries marked as related to the post named "Final Fantasy" in the "Game" post type, that are then in the "Journal" post type.
My issue is resolved now. Thank you!
Solution turned out bunk. Still need assistance please.
Okay it sounds like you have a post relationship between Games and Journals. On the single Journal page, you want to display all the sibling Journal posts. Is that correct? If so, then you can use a View of Journal posts filtered by this Post Relationship, where the parent post is set by a shortcode attribute "wpvrelatedto". The corresponding View shortcode looks something like this with a hard-coded parent ID:
[wpv-view name="Your Filtered View of Journals" wpvrelatedto="12345"]
Next you want to pass the current Journal's parent post ID into the View instead of 12345. The current Journal's parent post ID can be retrieved using the wpv-post-id shortcode like this:
[wpv-post-id item='@game-journal.parent']
If you use the Fields and Views button to insert the post ID shortcode, you can then use the Post Selection tab in the popup to choose a related post. The proper syntax for the shortcode will be generated automatically by the system. Finally, combine these two shortcodes like this:
[wpv-view name="Your Filtered View of Journals" wpvrelatedto="[wpv-post-id item='@game-journal.parent']"]
So, my concern is having to use the hardcoded ID. We have a number of editors and I'd like to make it more automatic than that. Is there no way to just display a list of journal posts in the series that have the specific game as the Game-Journal relationship?
As in, it reads it sort of as "If episodic review's Game is _______, then echo in sidebar of post" logic?
So, my concern is having to use the hardcoded ID.
You don't, the hardcoded ID in step 1 was used to illustrate how things fit together. The rest of the explanation shows you how to make this ID dynamic based on the current post using a combination of shortcodes.
Ah, I see, sorry I missed that phrasing.
I think I'm still doing something wrong. I've created a View for the related journals and assigned it to the post-type of said journals. I've told its template to just print the post name with its link.
Then I've created a content template for said journal post-type that prints the body of the journal text, and beneath it should print the list of related journal posts, as defined in the game-to-journal relationship (one-to-many). I've also used the shortcode you gave me, substituting the appropriate slugs. It prints nothing.
Is there a way I could give you access so maybe you could show me what I'm doing wrong?
Sure, please provide login credentials in the private reply fields here and let me know where to find this View on the front-end of your site. I'll take a closer look and see what's going on.
As a note on that, the view in question for listing is named Related Episodic Reviews - SIDEBAR, and the post-type Content Template is Episodic Reviews.
Okay I changed two things:
1. The post relationship slug is actually "game-with-episodic-content", not "game-journal" so I made the appropriate update in the view shortcode:
[wpv-view name="related-episodic-reviews-sidebar" wpvrelatedto="[wpv-post-id item='@game-with-episodic-content.parent']"]
2. The View "Related Episodic Reviews - SIDEBAR" has a post relationship Query Filter. That filter is set to display posts related to the post where this View is shown. That's not quite right, because the Episodic Reviews aren't related to one another directly. They're each related to the same Game, so it's an indirect relationship. I've updated the filter to respond to a shortcode attribute wpvrelatedto (see the screenshot), and now the filter is reading the parent Game ID from the wpv-post-id shortcode.
Thank you so much Christian, that was amazing!
Sorry, I just needed one more piece of assistance in case I need to call this in PHP. How would I wrap this tag using the do_shortcode command?
<?php do_shortcode("[wpv-view name='related-episodic-reviews-sidebar' wpvrelatedto='[wpv-post-id item="@game-with-episodic-content.parent"]']"); ?>
returns as an error.
Don't use do_shortcode to render a View, use the Views API render_view: https://toolset.com/documentation/programmer-reference/views-api/#render_view
If you have questions about that, feel free to open a separate ticket and we can discuss in more detail.