How can I rewrite URLs to pass taxonomy and post type values to the query?

Ok so I chucked the rewrite all together and went with a $_POST solution. It works really well and no slop in my URL. Here practice-areas is the taxonomy and the link pulls the taxonomy-practice-areas.php template file. On the destination (or here in the template file) I can modify the $query_string to further refine the search to a particular post-type. Yeeeee-ha!!

Put in Destination Page:

    <?php
    $myvar = $_POST['formVar'];
    query_posts($query_string . '&post_type=".$myvar );
    ?>

Put in Originating Page:

<!-- The Form: Put this form somewhere on the page: -->

    <form method=post name="post_form" action="">
    <input type="hidden" name="formVar" value="">
    </form>


<!-- The URL: Here I am assigning the Destination URL to a variable.  This can be whatever you want the destination page to be. -->

    <?php                       
    $dest_url = get_bloginfo("url').'/practice-areas/'. $category->slug;
    ?>


<!-- The Link: Here we are assigning 'portfolio' to  'formVar' and setting the form 'action' to the $dest_url value. The title stuff is irrelevant here-->

    <a href="" onclick="document.post_form.formVar.value="portfolio"; document.post_form.action ='<?php $dest_url; ?>'; document.post_form.submit(); return false" title ="<?php sprintf( __( "View all posts in %s" ), $category->name ); ?>" >

Leave a Comment