Recently we published an article to show random tags and posts in wordpress without using any plugin . But if you use too many tags the random tag cloud will become messy, so limiting maximum number of tags to be displayed in the tag cloud is required. If you are using the code that was written in the last post, you would just need to do a little bit of tweaking .
Here is what is needed to be done :-
Just use the following code :
<?php if ( function_exists(‘wp_tag_cloud’) ) : ?>
<?php wp_tag_cloud(‘smallest=8&largest=22&number=50&order=RAND&exclude=1,2′); ?>
<?php endif; ?>
Notice that in the above code I have added ‘number=50′ – It limits the maximum no. of tags to be displayed in the cloud to 50. You can use any number you want instead of 50.
Do share your views with us
Hi - Thanks for this post. I’m having one problem with the method you described:
I’m working on a test site that has these seven tags:
- tag 1
- tag 2
- tag 3
- tag 4
- tag 5
- tag 6
- tag 7
When I limit the number of tags to 4, it always displays the same four tags in a random order. However, I want it to select four different tags from the complete list every time.
I think I’m looking for the ‘orderby’ function to have a ‘RAND’ value, but currently all I can assign to it is ‘name’ or ‘count.’
Any help would be appreciated! Thanks…