Title: ryleef's Replies | WordPress.org

---

# ryleef

  [  ](https://wordpress.org/support/users/ryleef/)

 *   [Profile](https://wordpress.org/support/users/ryleef/)
 *   [Topics Started](https://wordpress.org/support/users/ryleef/topics/)
 *   [Replies Created](https://wordpress.org/support/users/ryleef/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/ryleef/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/ryleef/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/ryleef/engagements/)
 *   [Favorites](https://wordpress.org/support/users/ryleef/favorites/)

 Search replies:

## Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] Multiple Categories with 'AND' relation](https://wordpress.org/support/topic/multiple-categories-with-and-relation/)
 *  Thread Starter [ryleef](https://wordpress.org/support/users/ryleef/)
 * (@ryleef)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/multiple-categories-with-and-relation/#post-6178404)
 * Was able to “fix” this with the addition to the following code in `class-gallery.
   php`
 * ***NEW***
 *     ```
       foreach ($this->taxa as $taxon => $terms) {
                   $terms = $this->getTermIdsByNames($taxon, explode(',', $terms));
                   foreach($terms as $term){
                       $taxa[] = array(
                             'taxonomy' => $taxon,
                             'field'    => 'id',
                             'terms'    => $term,
                             'operator' => isset($operator[$taxon]) ? $operator[$taxon] : 'IN'
                       );
                   }
   
                }
       ```
   
 * ***OLD***
 *     ```
       foreach ($this->taxa as $taxon => $terms) {
                   $terms = $this->getTermIdsByNames($taxon, explode(',', $terms));
                       $taxa[] = array(
                             'taxonomy' => $taxon,
                             'field'    => 'id',
                             'terms'    => $terms,
                             'operator' => isset($operator[$taxon]) ? $operator[$taxon] : 'IN'
                       );
   
                }
       ```
   
 * Created a separate array for each term so that the ‘AND’ relation worked as expected.
 * If there is a “proper” way around this please comment below.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] Multiple Categories with 'AND' relation](https://wordpress.org/support/topic/multiple-categories-with-and-relation/)
 *  Thread Starter [ryleef](https://wordpress.org/support/users/ryleef/)
 * (@ryleef)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/multiple-categories-with-and-relation/#post-6178397)
 * From a quick debug, it seems like it ignores the first value (`form` in this 
   case) and only applies the second (`contractor`)
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] Multiple Categories with 'AND' relation](https://wordpress.org/support/topic/multiple-categories-with-and-relation/)
 *  Thread Starter [ryleef](https://wordpress.org/support/users/ryleef/)
 * (@ryleef)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/multiple-categories-with-and-relation/#post-6178394)
 * NOTE: I have also tested this with comma separated values:
 * `[dg descriptions=true fancy=true media_category=form,contractor relation=AND
   id=-1]`
 * This doesnt work and displays all files.
 * I have also tested with quotes surrounding values (`media_category="form"`)

Viewing 3 replies - 1 through 3 (of 3 total)