WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After much headache in the last week I feel like my problem is almost solved. I have been attempting to customize the admin edit.php page of custom post types to display and sort/filter custom taxonomies. I've frankensteined a collection of actions and filters from things found on the web but fear I may be using deprecated code as some of them were quite old.

I think I've narrowed the problem down to this filter

function convert_large_feature_id_to_taxonomy_term_in_query($query) {
    global $pagenow;
    $qv = &$query->query_vars;
    if ($pagenow=='edit.php' &&
            isset($qv['taxonomy']) && $qv['taxonomy']=='large_feature' &&
            isset($qv['term']) && is_numeric($qv['term'])) {
        $term = get_term_by('id',$qv['term'],'large_feature');
        $qv['term'] = $term->slug;

When I choose the dropdown menu for large_feature it accurately displays the "categories" (is that what you call them when they are of a custom taxonomy?) and post count, however when it is actually filtered, the query comes up empty. I noticed, however, that when I modified the query URL from




It displays as intended.

This leads me to believe that this filter isn't outputting the slug as it's supposed to... right?

share|improve this question
up vote 1 down vote accepted

taxonomy & term won't be set (in this case), since query vars are mapped from GET/POST.

In other words, $qv['large_feature'] = 291 (see wp_edit_posts_query() and WP_Query::get_posts() for the big picture).

add_filter( 'parse_query','convert_large_feature_id_to_taxonomy_term_in_query' );

function convert_large_feature_id_to_taxonomy_term_in_query( $query ) {
    global $pagenow;

    $qv =& $query->query_vars;

    if (
        $pagenow == 'edit.php' &&
        isset( $qv['large_feature'] ) &&
        ctype_digit( $qv['large_feature'] ) // stricter than is_numeric()
    ) {
        if ( $term = get_term_by( 'id', $qv['large_feature'], 'large_feature' ) )
            $qv['large_feature'] = $term->slug;
share|improve this answer
Beautiful! Thank you so much! – Kristina Childs Nov 12 '12 at 17:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.