Problem:
Add a parameter search field on the post type.
Solution:
It is possible within Views filter hook wpv_filter_query, for example:
1) edit your view, in section "Filter", add a select dropdown for post type filters into your filter form:
[wpml-string context="wpv-views"]Post Type:[/wpml-string] [wpv-control url_param="wpv-post-type" type="select" values=",page,post" display_values="All,Page,Post"]
2) add below codes into your theme/functions.php:
add_filter( 'wpv_filter_query', 'post_type_filter_func', 10, 3 ); function post_type_filter_func( $query_args, $settings, $view_id ) { if ( $view_id == 123 && isset($_GET['wpv-post-type'][0]) && !empty($_GET['wpv-post-type'][0]) ) { $query_args['post_type'] = $_GET['wpv-post-type'][0]; } return $query_args; }
Relevant Documentation:
https://toolset.com/documentation/user-guides/views-filters/wpv_filter_query/
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 3 voices.
Last updated by Guillaume 7 years, 7 months ago.
Assigned support staff: Luo Yang.