WordPress.org

Ready to get started?Download WordPress

Forums

Media Categories
[resolved] Gallery with Multiple Media Categories (7 posts)

  1. BLWBebopKid
    Member
    Posted 1 year ago #

    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.

    http://wordpress.org/extend/plugins/media-categories-2/

  2. BLWBebopKid
    Member
    Posted 1 year ago #

    Actually, it doesn't show any images with [gallery category=”cat1,cat2″]

  3. Eddie Moya
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  4. BLWBebopKid
    Member
    Posted 1 year ago #

    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.

  5. BLWBebopKid
    Member
    Posted 1 year ago #

    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(
                        array(
                            'taxonomy' => $mc_tax,
                            'field' => $term_field,
                            'terms' => $term
                        )
                    )
                );
  6. Eddie Moya
    Member
    Plugin Author

    Posted 1 year ago #

    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.

    https://github.com/eddiemoya/Media-Categories

  7. BLWBebopKid
    Member
    Posted 1 year ago #

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

    Thanks,

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags