Skip Navigation

[Resolved] Remove all filter

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 7 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#479966

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

#480162

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

#480417

Thanks for the reply Luo. Still not getting this. I read the other thread.

1) How do pick the default category to display?

#480794

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']

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.