Problem: I would like to display a View using PHP. The View displays sibling posts of the current post using a shortcode attribute in the post relationship filter.
Solution: Use the post relationships API to get the parent post ID, then pass that value into the render_view API using the shortcode attribute name as the key.
global $post; // the current episodic review post object. Depending on how you implement this code you may need to change this $parent_id = toolset_get_related_post( $post->ID, 'game-with-episodic-content', 'parent', array(), null ); $args = array( 'name' => 'related-episodic-reviews-sidebar', 'wpvrelatedto' => $parent_id ); echo render_view( $args );
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
https://toolset.com/documentation/programmer-reference/views-api/#render_view
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 |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 5 years, 9 months ago.
Assisted by: Christian Cox.