WordPress.org

Ready to get started?Download WordPress

Forums

Media Library Assistant
[resolved] Building an archive gallery with MLA (8 posts)

  1. Alexander S. Kunz
    Member
    Posted 1 year ago #

    Hello David,

    I was recently looking into adding a tag cloud to show all the attachment tags in a nice way, and while that works (with Better Tag Cloud) my theme seems to be missing the functionality to actually show the results of an archive search through the tag cloud (URL ending in .../attachment_tag/yellow or whatever doesn't give me any results).

    I was hoping to find a way to incorporate [mla_gallery] into the archives for attachment_tag and attachment_category, creating "archive galleries" for my image attachments. The result should be similar to this: http://www.alex-kunz.com/portfolio/blue/ (which simply shows all images tagged "blue" and renders them through Justified Image Grid, but I've set this up manually with a hard-coded tag "blue" of course).

    I do find an "archive.php" for my theme, but when used with attachment_tag or attachment_category, it doesn't return any results, so obviously, there is something missing.

    I would imagine this should actually be as simple as [mla_gallery attachment_tag="%S"] in an archive template, but I don't know where to start.

    I hope it's clear what I mean. :)

    Thanks
    Alexander.

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

  2. Alexander S. Kunz
    Member
    Posted 1 year ago #

    OK... I just found this thread:
    http://wordpress.org/support/topic/template-query-for-att-tags

    And it seems this is the right approach... apparently, I need a template "taxonomy-attachment_tag.php" for my theme. I copied the code from that thread and created it, but somehow, the passing of the parameter (the actual tag) doesn't seem to work... I have to wait for a fairly long time and then get a gallery with ALL images... duh. :)

    Any help would be appreciated.

    Thanks!
    Alexander.

  3. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Alex,

    Thanks for this question and for taking the time to work with the code posted in the "template query for att. tags" topic.

    I haven't worked with "Better Tag Cloud" and I don't know what form the URLs it generates take, i.e. what parameters they pass on to the destination page. If you can send me a link to a page with the page containing the Tag Cloud I can have a look. It would also be helpful to see the PHP source code for your taxonomy-attachment_tag.php script.

    I am traveling until July 18 and away from my development system, so my ability to try things out and get back to you is limited. I'll do my best and post my progress to this topic. Thanks for your patience.

  4. Alexander S. Kunz
    Member
    Posted 1 year ago #

    Hello David,

    thanks for the response. At the moment I'm using Better Tag Cloud in my weblog's sidebar to display the portfolio categories (which uses another custom taxonomy, "portfolio").

    You can find it here: http://www.alex-kunz.com/weblog/

    In my attempts, I simply typed a URL to an archive manually, like .../attachment_tag/trees

    As for the code; I really only used your example and adapted it to my theme where necessary. While cluelessly fiddling around I've found that $_REQUEST is empty... ?!

    Anyway... it's not urgent, it's just something I've meant to tackle for a while.

    I hope the travels are of an enjoyable nature! :)
    Alexander.

  5. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Alexander,

    Thanks for your patience - I'm traveling and have limited access to the support forum.

    You are close to a solution, I think. The $_REQUEST array will not help you because the taxonomy and term information is embedded in the URL and WordPress separates the URL components to formulate the archive page query. You can get access to the individual query parts by accessing the query_vars array within the global $wp_query object. For example, try adding this code somewhere on your page:


    <?php
    global $wp_query;
    echo var_export($wp_query->query_vars['attachment_category'], true) . '
    ';
    echo var_export($wp_query->query_vars['taxonomy'], true) . '
    ';
    echo var_export($wp_query->query_vars['term'], true) . '
    ';
    ?>

    You should see the taxonomy and term information echoed to the screen. you can then fix your do_shortcode statement to access $wp_query->query_vars['term'].

    I hope that gets you closer to a solution. Let me know how it goes.

  6. Alexander S. Kunz
    Member
    Posted 1 year ago #

    Hello David, thanks for the response. Using $wp_query->query_vars['term'] to get the tag did the trick. However, I ran into some other obstacles (the lightbox I'm using doesn't seem to work, you maybe remember that I pass MLA's query results through to another gallery shortcode in order to use Carousel), and that probably goes beyond the scope of this inquiry a good bit. :)

    Thank you for your help, which is most excellent, as usual. Have a nice weekend!
    Alexander.

  7. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    I'm glad your taxonomy access worked out so easily. Thanks for the positive feedback.

    I understand the issue with passing parameters through the Carousel/Gallery shortcode; I answered a similar question from another user about the Tiled Mosaic/Gallery just a few days back.

    Unfortunately, the [gallery] shortcode does not provide any way to edit the links it generates, add query arguments and so forth. I haven't found a way around this issue. I can imagine some sort of PHP-based post-processing using regular expressions to parse and modify the links, but it would be a chore. I regret the news isn't better.

  8. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    The "Pagination Revisited" topic now contains some good information on building a paginated gallery for taxonomy queries.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic