Forums

Customize Tag-Cloud via Functions (7 posts)

  1. Lou Sparx
    Member
    Posted 1 year ago #

    Hey,

    I'm currently using

    <h3>Tags</h3>
    <?php wp_tag_cloud('largest=48'); ?>

    I was wondering how I can apply "largest=48" via Functions.php to all calls of the tag-cloud on the sidebar?

    Something like:

    FUNCTION if: tag_cloud add: 'largest=48'

    Lou

  2. Lou Sparx
    Member
    Posted 1 year ago #

    Does anyone have any ideas? any code gurus out there?

  3. alchymyth
    The Sweeper
    Posted 1 year ago #

    (edit: this might reset all other parameters to default)

    for the default cloud widget:

    add_filter('widget_tag_cloud_args','set_largest_tags');
    function set_largest_tags($args) {
    $args = array('largest'    => 48);
    return $args;
    }

    edit 2: you can add multiple parameter into the array.
    http://codex.wordpress.org/Plugin_API/Filter_Reference

  4. Lou Sparx
    Member
    Posted 1 year ago #

    "this might reset all other parameters to default"

    Is this a bad thing? you mention "all other parameters" are you referring to just the tag-cloud parameters?

  5. Lou Sparx
    Member
    Posted 1 year ago #

    Either way, this got the job done :)

    Thanks so much, alchymyth.

    Lou

  6. alchymyth
    The Sweeper
    Posted 1 year ago #

    well done ;-)

    Is this a bad thing? you mention "all other parameters" are you referring to just the tag-cloud parameters?

    this is just referring to the tag cloud parameters; however, the good thing is that you can set as many parameters as you need to change.

  7. wagonlips
    Member
    Posted 1 year ago #

    This code works equally well to limit the number of tags displayed in the cloud with only minor changes:

    add_filter('widget_tag_cloud_args','set_number_tags');
    function set_number_tags($args) {
    $args = array('number' => 20);
    return $args;
    }

    Thanks, alchymyth

Topic Closed

This topic has been closed to new replies.

About this Topic