• Resolved Philbeaux

    (@philbeaux)


    David,
    I’ve been playing around with MLA Random Galleries plugin a bit and got it to display attachment tags instead of attachment categories. My question is how could I include multiple attachment tags to the pool of images or, better yet, exclude certain tags from all the attachment tags? the code I’m currently using is

    [mla_gallery random_category='philadelphia-eagles'
     numberposts=3 mla_caption="{+title+}" mla_alt_shortcode=justified_image_grid]

    the last bit of code is to get it to work with Justified Image Grid.

    the code in mla-random-galleries-example.php I’m using is

    private static $gallery_terms = array(
    		'oakland-raiders', 'dallas-cowboys', 'philadelphia-eagles',
    		);

    of course I’m only using 1 attachment tag at a time.

    • This topic was modified 8 years, 4 months ago by Philbeaux.
    • This topic was modified 8 years, 4 months ago by Philbeaux.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author David Lingren

    (@dglingren)

    Good to hear from you again! Thanks for working with me by email to clarify your application goal.

    The example plugin you found was intended to solve a somewhat different problem, i.e., it improves the performance of an application that originally had many separate SQL queries on one page. The example does one query and then organizes the results so they can be displayed in several separate gallery displays on the page.

    Your application is simpler. You want to pick one or two or a few “player” images at random. Taxonomies are a good solution, but they are better at “including” specific terms rather than “excluding” terms. If you can assign a specific attachment_category or attachment_tag term to all the players (and only the players) you can code something like:

    [mla_gallery attachment_tag=player numberposts=2 orderby=rand]

    It looks like you’ve assigned a “team” tag to your images. You could use a taxonomy query to randomly show players from a specific team:

    [mla_gallery]
    numberposts=2
    orderby=rand
    tax_query="array(
        array(
            'taxonomy' => 'attachment_tag',
            'field' => 'slug', 
            'terms' => array( 'player', 'oakland-raiders' ),
            'operator' => 'AND'
       ),
    ) "
    [/mla_gallery]
    

    That looks complicated but I’ve used the “enclosing shortcode” syntax to break it out over several lines for readability. If you follow the taxonomy query link above you’ll see several examples that show what can be done. Taxonomy queries are the WordPress-recommended way to do these searches, but MLA also supports the older, simpler format:

    [mla_gallery attachment_tag="player,oakland-raiders" tax_operator=AND numberposts=2 orderby=rand]

    You want to “randomly display one or two (or however many) in the side bar.” You can put an [mla_gallery] shortcode in a WordPress text widget (new feature in the latest WordPress version) or you can use the “MLA Text” widget I provided for older WordPress versions.

    I hope that gives you the information you need to accomplish your task. I am marking this topic resolved, but please update it or email me if you have any problems or further questions regarding the above suggestions. Thanks for your continued interest in the plugin.

Viewing 1 replies (of 1 total)

The topic ‘MLA Random Galleries Question’ is closed to new replies.