Community Forums › Forums › Archived Forums › Design Tips and Tricks › How can you change the font-size range in the tag cloud via functions.php?
- This topic has 7 replies, 4 voices, and was last updated 8 years, 10 months ago by
babrees.
-
AuthorPosts
-
April 2, 2013 at 2:49 am #32591
Chris Moore
MemberHello,
I tried changing the font-size in the tag cloud widget for the eleven40 child theme to no avail. It turns out that when you use the WordPress tag cloud widget you cannot alter the font-size via CSS. I don't want to use yet another plugin my friends, so would someone be so kind as to give me the exact php function and code snippet that I could use in my eleven40 child theme's functions.php file so that I can make the tag cloud font-size range go from 8pt up to 10pt (instead of up to 22pt, which is what it is right now).
Thanks!
~ Chris
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comApril 2, 2013 at 4:20 am #32599Chris Moore
MemberSolution City! I figured it out from this short tutorial here: http://chris.dziemborowicz.com/blog/2009/06/11/change-the-tag-cloud-font-size-in-wordpress-2-8/
I just used the short code snippet he shared and placed it in my child theme's functions.php. I ignored the suggestion of making it into a plugin.
Here's the code snippet I used in my child theme's functions.php:
function tcr_tag_cloud_filter($args = array()) {
$args['smallest'] = 8;
$args['largest'] = 12;
$args['unit'] = 'pt';
return $args;
}Followed by:
add_filter('widget_tag_cloud_args', 'tcr_tag_cloud_filter', 90);
Anything I need to lookout for or be aware of? Is there a "better" way to do this?
Thanks everyone!
~ Chris M.
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comApril 2, 2013 at 4:38 am #32600Chris Moore
MemberHere's an even shorter and "cleaner" way to do it (sharing for those who might find this thread):
http://wordpress.org/support/topic/different-font-sizes-for-tag-clouds#post-2948370
Here's what I ended up using for my purposes (I wanted it to be 8pt - 11pt in size):
add_filter('widget_tag_cloud_args','set_tag_cloud_sizes');
function set_tag_cloud_sizes($args) {
$args = array('smallest' => 8, 'largest' => 11);
return $args;
}
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comOctober 2, 2013 at 11:57 am #65090bello-via
MemberVery helpful. Thanks for updating the post with the code you used. Worked perfectly!
October 2, 2013 at 12:00 pm #65091Chris Moore
MemberHello @bello-via,
That's great! So glad it worked out for you. I can't count the number of times I have posted a question (here and elsewhere), only to just figure it out myself and post the answer. LOL...
Have a great day!
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comDecember 19, 2013 at 11:12 am #80237Mealtog
MemberNice, just got this to work Chris. Is there a way to add the number of tag items in () beside each tag?
December 19, 2013 at 2:13 pm #80306Chris Moore
MemberThanks @mealtog! Unfortunately, I don't have something ready-made for that. However, this may help you in your quest: http://dmblog.com/wordpress-tag-cloud-with-post-counts/
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comDecember 1, 2014 at 9:50 am #133337babrees
ParticipantThanks for this - just what I was looking for, works a treat!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.