After reading
Adding a Taxonomy Filter to Admin List for a Custom Post Type? I tried it but I wasn’t able to get it to filter two (2) different taxonomies at same time. The system is only filtering latest taxonomy and ignoring other one.
Does anyone know how to filter two taxonomies at same time?
I don’t have the time to actually write up a fully working example for you right now, but since you requested help in email I figured I would point you in the right direction.
As you may or may not know, this isn’t really an issue for the admin post listing; most all of that code should work fine. The issue is that currently WordPress does not have the ability to use
query_posts()
/get_posts()
/WP_Query
to filter on more than one taxonomy term without using hooks. (There is a very good chance that will change in v3.1; we can only hope!)The solution is to use a
'posts_where'
hook as illustrated here with thetax_terms_where()
function written for that answer:You’ll also need to modify the
'parse_query'
hook to capture your filter values, something like this (I have not tested this, so there may be small syntax errors):The above assumes you have dropdowns with names of
'marka'
and'konu'
. You’ll probably also need to tell WordPress to recognize them as query vars using an'admin_init'
hook. Again, I haven’t tested this so I’m hoping it works as written:That’s about it. Combine the knowledge of the three posts; this one, the one on admin lists, and the one on multiple taxonomy queries and I think you’ll get it done. You might even want to post your solution for others to learn from. Let me know if you get stuck.
Late answer
Update for WordPress 3.5+
I wrote the following plugin to extend the
WP_List_Table
s for built in and custom post types with the following features:show_admin_column
is set tofalse
)Here’s the plugin (best served as mu-plugin):
Explanation
First I did an awesome, but large work-around to get the custom columns in (didn’t know about the 3.5 update for
show_admin_column
). Then I did a lot toparse_query
to get it filter by two taxonomies. Luckily I instantly had a surprising result (with no code added). Look at the following example dump:WP already does this by default!