Problem:
The issue here is that the user wanted to create 1 single view but use it across multiple different archive and switching the post type of the view.
Solution:
This is possible by overwriting the post type query for your view.
Have a look at the custom query below.
add_filter( 'wpv_filter_query', 'filter_post_type_func', 99, 3 ); function filter_post_type_func( $query_args, $view_settings, $view_id ) { if ( in_array($view_id, array(20356)) ) { if ( is_post_type_archive( 'CPTsluggoes here' ) ){ $query_args['post_type'] = 'cptslug goes here'; } if ( is_post_type_archive( 'CPTsluggoes here' ) ){ $query_args['post_type'] = 'cptslug goes here'; } if ( is_post_type_archive( 'CPTsluggoes here ) ){ $query_args['post_type'] = 'cptslug goes here'; } } return $query_args; }
Replace the 20356 with the ID of your view and then replace "CPTsluggoes here" with the relevant slugs of your Custom Post Types.
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 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 2 replies, has 2 voices.
Last updated by 5 years, 7 months ago.
Assisted by: Shane.