Using tag cloud shortcode to display galleries
-
Firstly, I’m sure you’ve answered this before and I apologize for asking again, but WordPress’ plugin support forums are severely lacking in even basic features such as a usable search function.
I want to use the
[mla_tag_cloud]
shortcode to display a list of all image tags, which will link to a gallery for each tag when clicked. I have no problem displaying the tags using the basic shortcode with no parameters, but clicking on a tag directs to a blank page, instead of a gallery.I’ve tried to find an answer in the comprehensive documentation, but unfortunately I wasn’t able to modify any of the examples to work for me. It seems as though
taxonomy=attachment_category
is always used in the examples, but if I replace that withattachment_tag
which is what I believe I should be using, I can’t get the tag cloud to display anything.Maybe I’m just way off here, but it seems like the support for this plugin is excellent, so I might save myself some time by asking you directly.
Thanks in advance for your help, and for providing a great plugin.
https://www.ads-software.com/plugins/media-library-assistant/
-
Thanks for the good words and for your question regarding the
[mla_tag_cloud]
shortcode. I share your pain regarding the lack of useful search functions in the Repository. In fact, I recently raised the issue in a post on “Make WordPress Core”. There are 2,126 posts and counting in the MLA Support Forum, and I am using Microsoft Outlook to manage them. But I digress…If I understand your question and the things you’ve tried so far, there may be some confusion over which taxonomy or taxonomies are involved. If you code
[mla_tag_cloud]
with no parameters at all it will display terms from the WordPress “Tags” taxonomy. If you code[mla_tag_cloud taxonomy=attachment_category]
you will display terms from the MLA “Att. Tags” taxonomy. The first thing to determine is which taxonomy you’re using, and it sounds like your answer is “Tags”, not “Att. Tags”. You can confirm this by going to the taxonomy submenus under the “Media” menu and see which taxonomy contains the terms you’re using. You can also find the terms in the Media/Assistant submenu table if you have checked the “Screen Options” box to the left of the taxonomies you want to use.As you’ve seen, “clicking on a tag directs to a blank page, instead of a gallery.” That’s because the default link supplied for each term goes to the “archive page” for that term, and WordPress archive pages look for posts/pages, not attachments/images. This recent support topic might help you replace the default link with something that works better for you:
Cloud-related issues are also discussed in these topics:
How to display pad_counts for hierarchical taxonomies
Have a look at those topics and see if they help. Once you get the right taxonomy in the shortcode and develop a destination for the links you’ll be all set.
I will leave this topic unresolved for now. Let me know what else I can do to help. Thanks for your interest in the plugin.
Thanks a lot for the detailed response David, and I apologize for my terrible response time.
You’re correct in assuming that I was confusing the default WordPress “tags” with “attachment_tags”. You said
If you code [mla_tag_cloud taxonomy=attachment_category] you will display terms from the MLA “Att. Tags” taxonomy.
but I’m assuming you mean that it will display terms from the “attachment categories” taxonomy, correct? I don’t think it makes a difference to me whether I use attachments tags or attachment categories, and I tried creating both and assigning attachments to them, but I still can’t get it to display correctly.
I tried this code:
[mla_tag_cloud taxonomy=category number=0 mla_link_href="{+page_url+}?term_slug={+slug+}"][mla_gallery category_name="{+request:term_slug+}"]
from the thread you linked me to, replacingtaxonomy=category
withtaxonomy=attachment_category
but had no luck. The widget is populated with the attachment category terms and I can see that attachments are assigned to each category through the media submenu, but I’m still not getting a gallery to display correctly.Did I not modify that code correctly when I changed “attachment” to “attachment_category” or is there something else I’m missing here? Thanks again for your patience and excellent support, I really appreciate it.
Thank you for your response and for taking the time to post the source text for your shortcodes. You are very close to a working solution.
I set up a test page with your shortcodes and made some minor changes. Here is a combination that works on my test system:
[mla_tag_cloud taxonomy=attachment_category number=0 mla_link_href="{+page_url+}?term_slug={+slug+}"] [mla_gallery attachment_category="{+request:term_slug+}"]
As you can see, I made two changes:
- I changed the taxonomy parameter in the cloud to
attachment_category
. - I changed
category_name
, which searches the WordPress “Categories” taxonomy, toattachment_category
, which searches the “Att. Categories” taxonomy.
Give that a try and let me know how it goes.
I am marking this topic resolved, but please update it if you have any problems or further questions on combining the cloud and gallery shortcodes with taxonomy searches.
Thanks for the quick response, David.
I just tried changing the code to what you provided, but the result wasn’t what I was expecting. I’ll give you a link to the page so you can see what I mean – https://funkandlittle.net/funkgallery/
It looks like just about every image in the library is now displaying on the widget. When a term is clicked, ‘decks’ for example, the images tagged with that term do display correctly, however they appear in the widget, and not the main content area as I was hoping.
Any thoughts on what the issue is here? Thanks again for all your help.
Thanks for your update and for posting the link to your site’s page; very helpful. Your question raises two issues:
- The initial gallery display, when there’s no
term_slug
set, shows all of your images. - The
[mla_gallery]
display appears in the widget area, not in the page body.
The first issue is a property of the way WordPress processes the
attachment_category=""
parameter; it returns all images in the Library. Once theterm_slug
is set the gallery displays just the images with the assigned term. I am thinking of how to improve that in a future MLA version. In the interim you could fix it by adding some code to one of the “MLA Gallery filters (Hooks)” described in the Settings/Media Library Assistant Documentation tab. If that’s of interest, let me know and I will give you a more specific solution.The second issue is somewhat easier. The gallery of images will appear wherever the
[mla_gallery]
shortcode is placed. If you move the shortcode from the widget text into the body of the page, the gallery will appear there. Use the Text tab of the editor, not the Visual tab when you make you move. Give that a try and let me know how it goes.Thanks for the response David, sorry again for my bad response time. I’m working on this sporadically in between other projects.
What I ideally want to do is have the widget contain only the tags (or attachment categories, whichever taxonomy is easiest) with no images. When a tag is clicked, the gallery is populated in the body section, not the widget. Perhaps this is more difficult than I thought, because I don’t want to put the shortcode in the body and then have the tags listed there.
Is this feasible, or should I maybe just resort to putting the shortcode in the body and having the tags appear at the top of the page?
In response to your first question, it would be great if I could have that gallery NOT populate in the widget if the attachment category is left blank. I had a quick look through the hooks at the bottom of the documentation, but I think it’s a bit beyond my PHP knowledge.
I apologize again for taking a week to reply to you, I really do appreciate the help and I’ll try to be quicker next time.
Thanks for your update – delayed responses are no trouble at all.
I am still working on the “show nothing for blank category” issue; stay tuned for that.
You can leave the
[mla_tag_cloud]
shortcode in the widget and move the[mla_gallery]
shortcode to the body of the page. Have you tried that combination?If the widget appears on every page of your site you can change the links in the cloud to go to your gallery page. Let me know if you want help with that.
Thanks for the quick response, I appreciate it.
I only want the widget on this page, so that’s not a problem. However, using the gallery shortcode on the page seems to suffer from the same issue as the widget with the blank category. Clicking a term will load the correct gallery on the page, but before a term has been clicked every image is loaded on the page, as you can see here – https://funkandlittle.net/funkgallery/
So I suppose the blank category issue will have to be resolved first. Other than that it’s working perfectly, so thanks a lot for your help so far.
Thank you for your update and for your patience. I am happy to report that I have a solution for you, and embarrassed that I didn’t get to it sooner.
You can use a Content Template to suppress the gallery display until you pick a term. Try something like this:
[mla_gallery attachment_category="{+template:({+request:term_slug+}|a-bad-term)+}"]
In this example:
- The
template:
prefix says that this is a Content Template - The parentheses “()” around the two elements are used to group them into a list of alternatives
- The vertical bar “|” between the two elements means “stop when you get a non-empty alternative
{+request:term_slug+}
will be empty unless there is aterm_slug
in the URLa-bad-term
is a literal value (and thus never empty) which does not match any term in theattachment_category
taxonomy, so the gallery will be empty if this alternative is used.
You can read all about it in the “Content Templates” section of the Settings/Media Library Assistant Documentation tab, but the example should work as-is. Let me know if that resolves your final issue.
Your example worked perfectly, it’s now functioning exactly as I wanted.
Thanks so much for all your help, your support is amazing.
Hello David,
thank you verry much for your plugin and for your immense support.
I followed this thread and it led me to a nice result here.Instead of att-category, I used att-tag as the taxonomy and it works nice.
What I would love to have is the slug as text output, a kind of a headline saying : all pictures with the tag ‘slug’ as archive pages do.
Any idea?Greetings from Germany,
GeorgHello David, thanks for not responding too quick. ??
It gave me the chance to digg a liitle more and I have come to something that works for me. I will show you, maybe you have a more elegant Idea ??I created a new markup template named “headline”
Open: <div class="mla-headline"> <h3>[+template:([+request:term_slug+]|[+term_slug+]|No Title)+]</h3>
Close: </div>
I call it with
[mla_tag_cloud taxonomy=attachment_tag number=0 mla_link_href="{+page_url+}?term_slug={+slug+}"]
for the tag cloud and for the result:
[mla_gallery mla_markup=headline attachment_tag="{+template:({+request:term_slug+}|a-bad-term)+}"] [mla_gallery attachment_tag="{+template:({+request:term_slug+}|a-bad-term)+}" mla_alt_shortcode=justified_image_grid orderby=date_asc last_row=flexible load_more=click load_more_text=Mehr load_more_count_text="(noch *count* Bilder)" load_more_auto_width=off load_more_limit=21]
And for the look some css
.mla-headline h3 { margin: 0 !important; text-transform: capitalize; }
As I said, maybe there is a simple way and I must admit it was more of try and error than knowing what to do ??
Thanks for your very good plugin and your immense support!
Georg
Georg,
I am always happy when my delay in responding encourages creativity; thanks for your persistence.
You site looks great and the solution you found is a good one. Here are a few details you may find helpful:
- You could create an
mla_style
template and move your CSS there. You don’t say where the styles are now, so this may be unnecessary. - You might consider retaining the other classes and attributes in the “Open:” part, adding your
mla_headline
class to the values already present. Many themes and other plugins rely on some of this information. - Your use of the “capitalized” slug values is a good choice. You might consider passing the term name along with the slug if you would rather see the name in the heading. You could use
mla_link_href="{+page_url+}?term_slug={+slug+}&term_name={+name,url+}"
in the cloud and then<h3>[+template:([+request:term_name+]|No Title)+]</h3>
in the template.
The additional
[+term_slug+]
choice in your template will never be present;[+request:term_slug+]
is the proper way to get the value you are pagging in to the page.All in all, great work! Thanks for sharing your solution here so others can find it.
Ah….. thank you verry much. That solved my “german special character problem” AND the uppercase stuff ?? Nice work!
thinking about it …….. just curious … since you can assign a description to each tag …. would it be possibe to show that as well?
- I changed the taxonomy parameter in the cloud to
- The topic ‘Using tag cloud shortcode to display galleries’ is closed to new replies.