Support » Plugin: Media Categories » Gallery with Multiple Media Categories

  • Resolved BLWBebopKid


    I am brand new to wordpress as of this week, but I am a developer and managed to install Media Categories 1.5 today. I am trying to configure a gallery to show images with either “cat1″ or “cat2″ as the category.

    I tried [gallery category=”cat1,cat2″] but it only shows “cat2″ images.

    Even if I need to add some custom php code, if you could point me in the right direction or provide any information, I’d greatly appreciate it.

    Thanks so much.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Actually, it doesn’t show any images with [gallery category=”cat1,cat2″]

    Plugin Author Eddie Moya


    Unfortunately I dont think I added support for multiple categories to be added that way. Make sure it works with a single category first – I want to make sure your not experiencing some major bug. However, If memory serves, I dont think I ever made it allow for multiple categories. Although, that should be a simple feature to include in the next release.

    It is working for single categories.

    I’ve looked through the code, but as a wordpress newbie I’m lost as to where it parses the category, so I’d much appreciate it if you add that on the next release.

    Or if you point me in the right direction, I would be happy to send you any code I change so you could include in or modify for an update.

    Thanks so much.

    I finally found where to change the code:

    I added an if statement and an explode. I think the if statement isn’t needed since explode would return a one element array without a comma.

    if( !empty($$mc_tax) ){ 
                $term = ${$mc_tax};
    //BebopKid added this if statement to split the categories
                if( strpos($term,',') ){
    		$term = explode(',',$term);
    //End of BebopKid edit
                $term_field = (is_numeric($term)) ? 'id' : 'slug';
                $tax_query = array(
                    'tax_query' => array(
                            'taxonomy' => $mc_tax,
                            'field' => $term_field,
                            'terms' => $term

    Plugin Author Eddie Moya


    If you are familiar with git, I would appreciate if you could fork this plugin on github commit this and send a pull request. It would make it easier for me to integrate your change and it would give you credit in the commit history.

    I’ve never used it before, but I think I just did what you requested on github.


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Gallery with Multiple Media Categories’ is closed to new replies.