Adding a Taxonomy Filter to a Custom Post Type
- by ken
There is an amazing conversation from about two years ago on the Wordpress Answer site where a number of people came up with good solutions for adding a taxonomy filter to the admin screen for your custom post types (see URL for screen I'm referring to):
http://[yoursite.com]/wp-admin/edit.php?s&post_status=all&post_type=[post-type]
Anyway, I loved Michael's awesome contribution but in the end used Somatic's implementation with the hierarchy option from Manny. I wrapped it in a class - cuz that's how I like to do things -- and it ALMOST works. The dropdown appears but the values in the dropdown are all looking in the $_GET property for the taxonomies slug-name that you are filtering by. For some reason I don't get anything. I looked at the HTML of the dropdown and it appears ok to me. Here's a quick screen shot for some context:
You can tell from this that my post-type is called "exercise" and that the Taxonomy I'm trying to use as a filter is "actions". Here then is the HTML surrounding the dropdown list:
<select name="actions" id="actions" class="postform">
<option value="">Show all Actions</option>
<option value="ate-dinner">Ate dinner(1)</option>
<option value="went-running">Went running(1)</option>
</select>
I have also confirmed that all of the form elements are within the part of the DOM. And yet if I choose "Went running" and click on the filter button the URL query string comes back without ANY reference to what i've picked.
More explicitly, the page first loads with the following URL:
/wp-admin/edit.php?post_type=exercise
and after pressing the filter button while having picked "Went Running" as an option from the actions filter:
/wp-admin/edit.php?s&post_status=all&post_type=exercise&action=-1&m=0&actions&paged=1&mode=list&action2=-1
actually you can see a reference to an "actions" variable but it's set to nothing and as I now look in detail it appears that the moment I hit "filter" on the page it resets the filter dropdown to the default "Show All Actions". Can anyone help me with this?