• 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.

Viewing 1 replies (of 1 total)
  • Briteweb

    (@briteweb)

    Not sure if you are still looking for the answer, but for anyone else who might stumble up on this question as I did: https://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.

Viewing 1 replies (of 1 total)
  • The topic ‘register_taxonomy('query_var'=>true) causing empty media library’ is closed to new replies.