Support » Plugin: Query Multiple Taxonomies » [Plugin: Query Multiple Taxonomies] Show single post instead of category list

  • AJRyan6of7


    I’m wondering if there’s any way to get this plugin to take the user to a single post rather than a category list?

    For example, I am creating a product catalog, and for each product, I have two taxonomies: color and hardware. Currently, this widget will show two dropdowns, one for each taxonomy, and users can choose color and hardware. So far so good. Then, when the user clicks the “Submit” button, what comes up is a url that looks like this: which gives me a “list” of the posts that use the “bk” and “lte” taxonomy terms.

    My problem is that in my case, only one post would ever use those two taxonomy terms together. So, I’d like to take them directly to that post.

    I’m using a Custom Post type (products) to create the posts. Each post will be named using the same naming convention: ProductName-Color-Hardware. What I’d like to be able to do is maybe have a custom field with the product name (product1), insert that in and then insert the taxonomy terms after it.

    So, for example, instead of returning the url: .../?colors=bk&hardware=lte it would output: .../products/product1-color-hardware.

    I hope I explained that correctly. My goal is to have a sort of “configurator” of sorts for our product. Pick your color and hardware and you are taken directly to a page that shows you exactly what the product you want would look like.

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Plugin Author scribu


    The easiest way to achieve that would be by doing a redirect from the results page.

    Something like this (not tested):

    function redir_to_first_post() {
    	global $wp_query;
    	if ( is_tax() && 1 == $wp_query->post_count ) {
    		wp_redirect( get_permalink( $wp_query->posts[0]->ID ) );
    add_action('template_redirect', 'redir_to_first_post');

    Just drop it in your theme’s functions.php file.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Query Multiple Taxonomies] Show single post instead of category list’ is closed to new replies.