Views plugin provides an API, making it easy to display Views output using PHP.
When you ask for help or report issues, make sure to tell us all related information about your View and the data that you want to display using the Views API.
Viewing 15 topics - 361 through 375 (of 375 total)
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 );
Problem:
How to use views PHP API function get_view_query_results with third party custom plugin
Solution:
you should try to use the WordPress standard hook wp_loaded that will allow you to use the view's PHP API function with custom plugin in this case.
Problem:
When updating Toolset this error appears: The package could not be installed. PCLZIP_ERR_BAD_FORMAT (-10) unable to find end of central Dir Record signature.
Solution:
This issue was solved in previous Toolset versions.
If you see this again please contact us.
Problem:
How to use the Views API on WordPress Archives?
Solution:
WordPress archives do not support the Views API.
Only
pre_get_posts
will work on archives.
You can, however, add queries to the Archive by setting them in the Toolset WordPress archive, if you enable the full custom view (Screen options of the archive)
There, you can add queries by fields, terms, and more.
Problem: I have a View that shows Events as a list, and also on a map. If the Event is "private", I do not want to show it on the map but I want it to appear in the results.
Solution: Use a checkbox field or a radio field to set the public / private status of each item. Use conditional HTML to show or not show the map marker for each result.