WordPress.org

Ready to get started?Download WordPress

Forums

Media Library Assistant
[resolved] Excluding a category (3 posts)

  1. Joe Alberts
    Member
    Posted 1 year ago #

    I'm wondering if anyone knows a way to do this with just MLA's attachment_category and tax_operator functions.

    I've got 2 attachment categories that I'm generating a PDF gallery of with all of them in 1 of the categories, and only some in the second. I would like to split the galleries up, based on that second category. Here's what I'm using (category names made generic):

    [mla_gallery tax_query="array('relation' => 'AND', array('taxonomy' => 'attachment_category','field' => 'slug','terms' => 'category-1'),array('taxonomy' => 'attachment_category','field' => 'slug','terms' => 'category-2','operator' => 'NOT IN'))" mla_caption="{+title+}" post_mime_type="application/pdf" link="file" mla_target="_blank" mla_viewer="true" mla_viewer_width="150"]

    It's more a point of curiosity. It would make it substantially easier for my other users if they didn't have to be able to construct a tax_query argument for this sort of thing.

    Thanks! Really liking this plugin so far.

    http://wordpress.org/extend/plugins/media-library-assistant/

  2. Joe Alberts
    Member
    Posted 1 year ago #

    I guess as a point of clarification, the above is what I'm using to get everything not included in my secondary category, I then make use of attachment_category and tax_operator to get the gallery for my subset (member of both categories):

    [mla_gallery attachment_category='category-1,category-2' tax_operator='AND' mla_caption="{+title+}" post_mime_type="application/pdf" link="file" mla_target="_blank" mla_viewer="true" mla_viewer_width="150"]

  3. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Joe,

    Thanks for the good words and for putting this example together. You have solved your query task in the best way I know of.

    MLA uses the WordPress database classes for populating galleries and doesn't do much manipulation of its own. The tax_query parameters are, as you note, somewhat complex but they are also the most general query interface WordPress provides. So far, I haven't thought of any way to simplify them while retaining all of the power they make available.

    If anyone else has a suggestion I hope they post it here. Thanks again for your interest.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic