Make empty queries filter automatically by custom post type of archive
-
Hello fellow wordpress users,
I have a series of dropdowns on each of my custom post type archives. I want to set up the site so that if none of these dropdowns are set, or even if they are, the base URL of the query string limits results to that particular post type. So on the resource archive, the query string will be “example.com/post_type=resource&topic=bananas&timeline=” while in the animation archive, the query string will be “example.com/post_type=animation&topic=bananas&timeline=”
Still struggling but after a few hours I think that this code looks close to what it should… though it still doesn’t work!
function my_qmt_base_url() { if (is_post_type_archive()) { $CPTquery = get_post_type( $post->name ); } return add_query_arg( 'post_type', $CPTquery ); } add_filter( 'qmt_base_url', 'my_qmt_base_url' );
I’m just not sure if I’m calling the post_type name properly, because this code doesn’t seem to affect my URL… Though I have tested it with “return ‘TEST’;” and that does affect the URL properly. As it stands, post_type is just not included in the query string.
Any help is much appreciated.
http://wordpress.org/extend/plugins/query-multiple-taxonomies/
- The topic ‘Make empty queries filter automatically by custom post type of archive’ is closed to new replies.