WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Query Multiple Taxonomies] Search a single Custom Post Type

[Plugin: Query Multiple Taxonomies] Search a single Custom Post Type

  • Hi right n00b to wordpress here.

    First of, Scribu this is an excellent plugin and pretty much does 80-90% (maybe more) of what I need. My scenario is I have 3 Custom Post types (post, case-studies & resources). They all share the same taxonomies (subject, sector, age-range).

    What I need to achieve is present the widget on three separate pages (post, case-studies & resources) and thus when the user builds up the taxonomy filters it just pulls back results for the appropriate post type. Kinda like a dedicated Case Studies filter page and a dedicated Resources filter page.

    I tried this on my functions.php file but doesn’t seem to do anything

    function my_qmt_post_type() {
    return 'resources';
    }
    add_filter('qmt_post_type', 'my_qmt_post_type');

    b.t.w I’m using version 1.2.3 of the plugin.

    many thanks

    KB

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author scribu

    @scribu

    First of all, you will have to switch to the development version (1.3-alpha7).

    Then, just add this code to your functions.php:

    function my_qmt_url($url) {
    	// post type => associated page slug
    	$map = array(
    		'post' => 'posts',
    		'case-study' => 'case-studies',
    		'resource' => 'resources'
    	);
    
    	foreach ( $map as $post_type => $page_slug ) {
    		if ( is_page( $page_slug ) ) {
    			$url = add_query_arg( 'post_type', $post_type, $url );
    			break;
    		}
    	}
    
    	return $url;
    }
    add_filter( 'qmt_url', 'my_qmt_url' );

    Of course, you can customize the $map variable to match your page slugs etc.

    Thanks, will give that a go.

    I’ve started to think my content might be better organized using Categories rather than Custom Post Types.

    So how about (similar principle as above) but filtering within “Categories”?

    Many Thanks

    Plugin Author scribu

    @scribu

    Just replace post_type with category_name.

    Just downloaded the development version, very nice the way list items work – in the previous version I had to add the widget X number of times.

    Just a thought, I noticed with both drop-down and list items, when you select one it filters the results and tells you what filter you’ve picked, but if you select more than one it just says “Posts classified under”: filter X.

    It would be cool if it could list the filters you’ve selected. If that makes sense

    Plugin Author scribu

    @scribu

    Just a thought, I noticed with both drop-down and list items, when you select one it filters the results and tells you what filter you’ve picked, but if you select more than one it just says “Posts classified under”: filter X.

    That’s probably something your theme is doing. You can extend it to display multiple filters by using qmt_get_query().

    Hi there,
    I have similar query but am working on current version. How do I use the widget to search only one post type, and not all?
    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Query Multiple Taxonomies] Search a single Custom Post Type’ is closed to new replies.