WordPress.org

Ready to get started?Download WordPress

Forums

register_taxonomy('query_var'=>true) causing empty media library (2 posts)

  1. davidsword
    Member
    Posted 3 years ago #

    Normally after looking up source code, or googling I can figure these things out, but this one has me scratching my head...

    register_taxonomy() with $args with 'query_var' => true in my themes functions.php is causing an empty pop-up media library page that usually shows all my files..

    Playing around in the source code, I found that when I set 'query_var' => true, the array that prints the media items ($GLOBALS['wp_the_query']->posts in get_media_items() in media.php) is empty, instead of the 100s of posts that show when query_var => false

    As I do need to query the var on the site, but not the admin, I've made this bandaid solution:

    $queryvar = (is_admin()) ? false : true;
    
    register_taxonomy( ... , ... , array(
    	...
    	'query_var' => $queryvar,
    	...
    ));

    But I've found lots of people online with the same issue, but no resolve on any threads, so my snippet above might be of help- but if anyone could shed some light on what's going on that'd be great.

  2. Briteweb
    Member
    Posted 2 years ago #

    Not sure if you are still looking for the answer, but for anyone else who might stumble up on this question as I did: http://wpquestions.com/question/show/id/678

    The issue is caused by using a reserved word as the taxonomy name. In my case I was using "type" as the taxonomy name, changing it fixed the media library. I have not been able to find a list of reserved words, so I guess it's a trial and error solution.

Topic Closed

This topic has been closed to new replies.

About this Topic