I am trying to: Remove the default filter option and pick another category to display onload
I visited this URL: hidden link
I expected to see:
Instead, I got:
Here is a screenshot: hidden link
Dear ryan,
Are you going to display only posts within a specific "category" in default?
There isn't such a feature within Views, but you can create a custom shortcode for it, see another similar thread:
https://toolset.com/forums/topic/display-default-value-in-a-parametric-search-filter/#post-375967
Thanks for the reply Luo. Still not getting this. I read the other thread.
1) How do pick the default category to display?
In the above thread, the default category is picked by the shortcode attribute:
[default-available-countries available_countries='Hongkong']
In your case, you can try this simply:
1) Modify the PHP codes in your theme/functions.php as below:
add_shortcode('set-default-category', 'default_category_func');
function default_category_func($atts, $content){
$atts = shortcode_atts( array(
'default_category' => 'santa-monica',
'url_param' => 'wpvcategory',
), $atts);
if(!isset($_GET[$atts['url_param']][0]) || $_GET[$atts['url_param']][0] == ''){
$_GET[$atts['url_param']][0] = $atts['default_category'];
}
return;
}
2) put above shortcode [set-default-category] just before the views shortcode [wpv-view ... ], for example:
[set-default-category default_category='santa-monica']