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,651 through 1,665 (of 3,129 total)
Problem: I have set my map initial zoom level to center and zoom in to show all the markers, but when I display the map the initial zoom level is zoomed out showing the entire global map.
Solution: In this case the map is not displayed when the page is loaded, so the initial zoom level calculations are inaccurate. You must trigger a map reload function when the map is displayed to calculate the initial zoom level correctly. The correct function to call is:
WPViews.view_addon_maps.reload_map("map-id");
Place that code after the code used to turn on the map display, and replace map-id with the ID of your map.
Problem: I would like to prevent search results from appearing until a custom search filter is added.
Solution: Use our PHP Views Filter API wpv_filter_query_post_process to drop a View's results until some meta_query is added. The following custom code can be used as a template:
/**
* No initial results until a filter has been applied
* Tests for one specific custom field search filter
* Reference: https://toolset.com/forums/topic/how-to-disable-the-search-in-view-using-blank/
*/
function tssupp_no_initial_results( $query_results, $view_settings, $view_id ){
$target_views = array( 123, 456 );
$field_slug = 'field-slug';
// you should not edit below this line
if ( in_array( $view_id, $target_views ) ) {
// blank search indicates just blank space in the filter
$blank_search = isset($query_results->query['meta_query']) && sizeof($query_results->query['meta_query']) == 2 && $query_results->query['meta_query'][0]['key'] == 'wpcf-'.$field_slug && trim($query_results->query['meta_query'][0]['value']) == '';
// if there is no search term set, drop all results
if ( !isset( $query_results->query['meta_query'] ) || $blank_search ) {
$query_results->posts = array();
$query_results->post_count = 0;
$query_results->found_posts = 0;
}
}
return $query_results;
}
add_filter( 'wpv_filter_query_post_process', 'tssupp_no_initial_results', 10, 3 );