How many tags will display in the tag cloud and how do you limit the count?

Community Forums Forums Design Tips and Tricks How many tags will display in the tag cloud and how do you limit the count?

This topic is: resolved

This topic contains 2 replies, has 1 voice, and was last updated by  Chris Moore 1 year, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #42884

    Chris Moore
    Participant
    Post count: 136

    Hello all!

    I am using a tag cloud widget on the lefthand side of my main blog and I was wondering how many items will display in the tag cloud. I would ideally like to limit it to the top 20 items. I have already limited the font size of the tag cloud with this code in the `functions.php` file.

    `/** Add a filter to change the tag cloud font-size range */
    add_filter(‘widget_tag_cloud_args’,’set_tag_cloud_sizes’);
    function set_tag_cloud_sizes($args) {
    $args = array(‘smallest’ => 8, ‘largest’ => 11);
    return $args;
    }`

    What filter or function would I need to add to limit the number of tag cloud items to the top 20? What is the exact code I would need (assuming I don’t know that much PHP, which is the case)?

    Thanks!


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    #42885

    Chris Moore
    Participant
    Post count: 136

    I’m sure this will be of help to those that know all the details of PHP:

    http://codex.wordpress.org/Function_Reference/wp_tag_cloud


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    #42887

    Chris Moore
    Participant
    Post count: 136

    Haha… Poking around, I figured it out!

    But now my question is, is this the best and most elegant way to accomplish the task at hand?

    Thanks for your feedback… Here’s the code I’m using in `functions.php`:

    `/** Add a filter to change the tag cloud font-size range and number */
    add_filter(‘widget_tag_cloud_args’,’set_tag_cloud_size_number’);
    function set_tag_cloud_size_number($args) {
    $args = array(‘smallest’ => 8, ‘largest’ => 11, ‘number’ => 20);
    return $args;
    }`


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    • This reply was modified 1 year, 2 months ago by  Chris Moore.
    • This reply was modified 1 year, 2 months ago by  Chris Moore.
    • This reply was modified 1 year, 2 months ago by  Chris Moore.
    • This reply was modified 1 year, 2 months ago by  Chris Moore.
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.