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.
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.
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.
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.
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.
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.
The “Pagination Revisited” topic now contains some good information on building a paginated gallery for taxonomy queries.