Views is a WordPress plugin that lets you easily display content on your website's front-end in any way you choose.
Views User Guides include detailed documentation for creating lists of content, templates for content and archive page and also explain how to create parametric searches for any content type.
When you ask for help or report issues, make sure to tell us the versions of the Toolset plugins that you have installed and activated.
Viewing 15 topics - 1,531 through 1,545 (of 2,104 total)
Problem: I have a View that I would like to filter by post author. That View may be displayed in a BuddyPress profile. I have a PHP function provided by BB that will help determine the User ID based on the profile being displayed.
Solution: Use the Views Filter API wpv_filter_query to programmatically set a post author filter in this View using the function provided by BuddyPress / BuddyBoss.
// Override the post author filter of a View shown in the BP User page to display only that User's posts.
// https://toolset.com/forums/topic/filtering-views-query-by-author-for-a-profile-page/
add_filter( 'wpv_filter_query', 'tssupp_bp_force_author_filter',99,3 );
function tssupp_bp_force_author_filter( $query_args,$views_settings, $view_id) {
$views = array( 123, 456 );
if ( in_array( $view_id, $views ) ){
// post author equals bp_displayed_user_id() if function exists
$query_args['author'] = function_exists('bp_displayed_user_id') ? bp_displayed_user_id() : 0;
}
return $query_args;
}
You would replace 123, 456 with a comma-separated list of View IDs which you would like to filter by post author. This post author filter will only work if the function provided by BP/BB returns the correct User ID. If you try to place this View on a page where the BP/BB function does not return the correct value, the View will not be filtered appropriately.
Problem: I have a many-to-many relationship between two custom post types. In a two-column table View, I want to display the title of each post from post type A in the left column. In the right column, I want to display the average value of a custom field in all the related Type B posts.
Solution: There's nothing exactly like this built into the system, so it's probably best to create a custom shortcode that can be used to query related posts and calculate the average custom field value. See examples below.
Problem: I have created an archive of WooCommerce Products that includes a wpv-woo-product-images shortcode to display the Product Image Gallery in each listing. The page itself loads quickly, but it seems that the results of the archive are hidden for a few seconds before they appear. I would like to display the results quickly.
Solution: To prevent the hidden listings upon page load, turn off the "Preload images before transition" option in the Archive's Pagination and Sliders panel > Advanced Settings area.