Title: Include all categories except one
Last modified: March 1, 2018

---

# Include all categories except one

 *  Resolved [jeffbarclay](https://wordpress.org/support/users/jeffbarclay/)
 * (@jeffbarclay)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/include-all-categories-except-one/)
 * Looking to show all media files both images and files with an icon / title but
   exclude a specific category or two.
 * the following gives me all files with icon and title
    [mla_gallery post_parent
   =all post_mime_type=all size=icon mla_caption=”{+title+}”]
 * how would I exclude certain categories or att cat.?
 * also want the open file when clicked and not direct to secondary page to open
   the file
    -  This topic was modified 8 years, 2 months ago by [jeffbarclay](https://wordpress.org/support/users/jeffbarclay/).

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

 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/include-all-categories-except-one/#post-10030365)
 * Thanks for your question and for including the source text of your `[mla_gallery]`
   shortcode; very helpful.
 * You can use MLA’s “Simple Taxonomy Parameters” or the more powerful “Taxonomy
   Queries” to accomplish your task. More information on both of these can be found
   in the corresponding sections of the Settings/Media Library Assistant Documentation
   tab.
 * For your application, the “Simple Taxonomy Parameters” solution would be something
   like:
 *     ```
       [mla_gallery]
       attachment_category="some-term"
       tax_operator="NOT IN"
       tax_include_children="false"
       post_mime_type=all
       size=icon
       link=file
       mla_caption="{+title+}"
       [/mla_gallery]
       ```
   
 * I have used the alternate “enclosing shortcode” syntax to break up the query 
   for readability and to avoid some WordPress parsing problems for complex shortcodes.
   
   The first parameter names the taxonomy you want and the term to exclude. The 
   second parameter specifies the “exclude” condition you want. These replace the`
   post_parent=all` parameter in your original query, which is not needed when taxonomies
   are involved. I also added `link=file` to open the file when clicked.
 * The “Taxonomy Query” solution looks something like this:
 *     ```
       [mla_gallery]
       tax_query="array(
           array(
               'taxonomy'=>'attachment_category',
               'field'=>'slug',
               'terms'=> array('some-term'),
               'operator' => 'NOT IN',
               'include_children' => false
           ),
       )"
       post_mime_type=all
       size=icon
       link=file
       mla_caption="{+title+}"
       [/mla_gallery]
       ```
   
 * Either one should work. I have added “include children’ false to both examples.
   If your taxonomy has more than one level you can experiment with this optional
   parameter depending on how you assign terms to your items. If you leave it out
   children will be included in the results.
 * Also, if some items in your Media Library do not have **any** terms assigned 
   you may not get the results you expect. This earlier topic has more information:
 * [MLA Gallery with items without category](https://wordpress.org/support/topic/wla-gallery-with-items-without-category/)
 * I am marking this topic resolved, but please update it if you have problems or
   further questions regarding the above suggestions. Thanks for your interest in
   the plugin.
 *  Thread Starter [jeffbarclay](https://wordpress.org/support/users/jeffbarclay/)
 * (@jeffbarclay)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/include-all-categories-except-one/#post-10031377)
 * Thanks David
 * both examples produce the same error:
 * ERROR: Invalid mla_gallery tax_query = ‘Personal’
 * I’m also not sure what the ‘some-term’ should be? Is this just a name for the
   array?:
    ‘terms’=> array(‘some-term’),
    -  This reply was modified 8 years, 2 months ago by [jeffbarclay](https://wordpress.org/support/users/jeffbarclay/).
    -  This reply was modified 8 years, 2 months ago by [jeffbarclay](https://wordpress.org/support/users/jeffbarclay/).
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/include-all-categories-except-one/#post-10033172)
 * Thanks for trying my suggestions and posting your update.
 * Since the word “Personal” doesn’t appear in the shortcodes above I am guessing
   that there is some sort of syntax or punctuation error in the code you entered.
   For example, you might have curly/smart quote characters in place of the plain
   quote characters around the parameter values, or an HTML escape character in 
   place of the “greater than” symbol.
 * Are you using the “Text” tab of the editor, not the “Visual” tab?
    Have you looked
   carefully for the errors I mentioned?
 * The `some-term` value is a placeholder for the slug of the term you want to exclude
   from the results. For example, if you assigned terms like “Cat”, Dog” and “Mouse”
   and you want to exclude mice, you would code
 * `'terms' => array ( 'mouse' ),`
 * You can find the Slug values for your terms on the taxonomy edit screens, e.g.,
   the Media/Att. Categories screen.
 * If you still have trouble with the invalid tax_query, can you post the entire
   source text of your page/post? Thanks for any additional information you can 
   supply.
 *  Thread Starter [jeffbarclay](https://wordpress.org/support/users/jeffbarclay/)
 * (@jeffbarclay)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/include-all-categories-except-one/#post-10033709)
 * Ok, I was using the “text” tab so thats out, and “Personal” is a category with
   slug that I have in the media section. strange that its showing in the error?
 * Here is my page, its a bunch of test shortcode to see what gets displayed. All
   work except the one we are working with. I’m excluding the “selfies” but thats
   not working, I have tried others as well. even a non-existent one should still
   show all the valid ones I would think.
 * I had a few of the same slug names in both category and attachment_catagory, 
   so I cleaned those up to see if that was the conflict. same “Personal” error!
 * here is my test page:
 * Firehouse Selfies:
    [mla_gallery attachment_category=selfies columns=5 rows=10]
 * Personal Category:
    [mla_gallery attachment_category=personal]
 * mime:
    [mla_gallery post_type=post post_status=publish post_mime_type=all] pdf(
   cat) [mla_gallery post_mime_type=all category=pdf] pdf (alt cat) [mla_gallery
   post_mime_type=all attachment_category=pdf] pdf/icon [mla_gallery post_parent
   =all post_mime_type=application/pdf size=icon link=file] – [mla_gallery post_parent
   =all post_mime_type=application/pdf size=icon mla_caption=”{+title+}”]
 * PDF:
    [mla_gallery post_parent=all post_mime_type=application/pdf]
 * RTF:
    [mla_gallery post_parent=all post_mime_type=application/rtf size=icon mla_caption
   =”{+title+}”]
 * ALL:
    [mla_gallery post_parent=all post_mime_type=all size=icon mla_caption=”{
   +title+}”]
 * [mla_gallery]
    tax_query=”array( array( ‘taxonomy’=>’attachment_category’, ‘field’
   =>’slug’, ‘terms’=> array(‘selfies’), ‘operator’ => ‘NOT IN’, ‘include_children’
   => false ), )” post_mime_type=all size=icon link=file mla_caption=”{+title+}”[/
   mla_gallery]
    -  This reply was modified 8 years, 2 months ago by [jeffbarclay](https://wordpress.org/support/users/jeffbarclay/).
    -  This reply was modified 8 years, 2 months ago by [jeffbarclay](https://wordpress.org/support/users/jeffbarclay/).
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/include-all-categories-except-one/#post-10034076)
 * Thanks for your update with the full text of your testing page. You have encountered
   a subtle WordPress shortcode=parsing issue that has tripped me up several times
   in the past.
 * You have many shortcodes on the page. All but the last one use the normal shortcode
   syntax with the name and parameters enclosed by square brackets. The last one
   uses the enclosing syntax, with a separate `[/mla_gallery]` to close the shortcode.
 * The problem is that WordPress looks for the `[\mla_gallery]` first and “matches”
   it with the first shortcode on the page ( `[mla_gallery attachment_category=selfies
   columns=5 rows=10]` ). That “encloses” everything between the two and so “Personal”
   is interpreted as a shortcode parameter, which fails.
 * The “Invalid mla_gallery tax_query = ‘Personal’” message is misleading. I’ve 
   never found a good way to fix that and I regret the confusion it caused.
 * If you move your last shortcode up to the top of the page so the `[/mla_gallery]`
   closes it properly all should be well. Let me know if that works for you.
 *  Thread Starter [jeffbarclay](https://wordpress.org/support/users/jeffbarclay/)
 * (@jeffbarclay)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/include-all-categories-except-one/#post-10034215)
 * Thanks for the fix!
 * That works perfect. I was test several different examples on the same page, but
   don’t need that as a final result. This will work fine… Great plugin and tons
   of great features not to mention the tech support!!!
 * As an FYI I did move it to the top and it renders as desired, but the rest of
   the examples fail with the same error code… Not an issue for me!
 * Thanks again for the great troubleshooting!

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

The topic ‘Include all categories except one’ is closed to new replies.

 * ![](https://ps.w.org/media-library-assistant/assets/icon-256x256.png?rev=973502)
 * [Media Library Assistant](https://wordpress.org/plugins/media-library-assistant/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/media-library-assistant/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/media-library-assistant/)
 * [Active Topics](https://wordpress.org/support/plugin/media-library-assistant/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/media-library-assistant/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/media-library-assistant/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)

 * 6 replies
 * 2 participants
 * Last reply from: [jeffbarclay](https://wordpress.org/support/users/jeffbarclay/)
 * Last activity: [8 years, 2 months ago](https://wordpress.org/support/topic/include-all-categories-except-one/#post-10034215)
 * Status: resolved