WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Tag Cloud into List (10 posts)

  1. WebsiteNewbie
    Member
    Posted 1 year ago #

    Hi,
    How do I turn a tag cloud into a list? I don't know anything about codes.
    Thanks.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    where?
    - in a template with direct code?
    the function is:
    http://codex.wordpress.org/Function_Reference/wp_tag_cloud

    the parameter is: http://codex.wordpress.org/Function_Reference/wp_tag_cloud#Parameters
    'format=list'

    - using the default 'tag cloud' widget in the sidebar?

    you could add a filter function into functions.php of your theme;
    example:

    add_filter('widget_tag_cloud_args','edit_args_tag_cloud_widget');
    function edit_args_tag_cloud_widget($args) {
    $args = array('format' => 'list');
    return $args;
    }
  3. WebsiteNewbie
    Member
    Posted 1 year ago #

    Thanks for responding.
    This is what I see when I try to edit the theme. I'm using Box of Boom.

    /* tag-cloud widget */
    .widget_links {}
    .widget_links li:after {}
    .widget_links li:before {}
    .widget_tag_cloud {}
    .widget_tag_cloud a { padding-right:8px; line-height:1.25em; }
    .widget_tag_cloud a:after { content:","; }
    .widget_tag_cloud a:before {}

    I know I'm supposed to put this:
    <?php wp_tag_cloud('smallest=10&largest=10&format=list&unit=px'); ?>

    But I don't know where to put it. When I just paste it into editor, it doesn't change anything.

    Thanks.

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    This is what I see when I try to edit the theme.

    youare looking at a stylesheet, which is the wrong file.

    where is the tag clous showing in your site?

    if in a side column, then you possibly need to edit sidebar.php - or you might be using the 'tag cloud' widget.

    How do I turn a tag cloud into a list?

    why do you want/need to do this anyway?

  5. WebsiteNewbie
    Member
    Posted 1 year ago #

    I followed your earlier instruction and the list worked! However, the list has commas at the end as in
    A,
    B,
    C,
    and also some are bigger than others like they were in the cloud. Any idea on how I can make the words all the same size?
    The reason I want to do this is that I like the way a list looks better than the cloud. I am using side column widget.
    Thanks.

  6. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    followed your earlier instruction

    please post the exact code you have used.

    have you set the 'smallest' and 'largest' parameters to the same value, as you had in your line of code?

    example:

    add_filter('widget_tag_cloud_args','edit_args_tag_cloud_widget');
    function edit_args_tag_cloud_widget($args) {
    $args = array('format' => 'list','smallest' => 10,'largest' => 10);
    return $args;
    }

    commas are not part of the default tag list fomatting; to illustrate where these a coming from, please post a link to your site with the tag list visible.

  7. WebsiteNewbie
    Member
    Posted 1 year ago #

    http://www.whataboutstocks.com/ Under "Read by Topic"
    It's just the commas now that I can't get rid of. Thanks for all of your help.

  8. WebsiteNewbie
    Member
    Posted 1 year ago #

    Also (sorry for being such a bother) -- how does one put the count of articles beside each tag on the list? The way archives has a count like
    August (4)
    July (5)
    ??
    Thanks.

  9. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    to start with, the commas are not in the html code;
    it comes from some (weird ?) formatting of the tag cloud widget from style.css of your theme:

    /* tag-cloud widget */
    	.widget_links {}
    	.widget_links li:after {}
    	.widget_links li:before {}
    	.widget_tag_cloud {}
    	.widget_tag_cloud a { padding-right:8px; line-height:1.25em; }
    	.widget_tag_cloud a:after { content:","; }
    	.widget_tag_cloud a:before {}

    change this one line for instance to:

    .widget_tag_cloud a:after { content:""; }

    to get the numbers behind the tag names, you could try to use another filter function;

    example (not widely tested):

    add_filter ( 'wp_tag_cloud', 'show_tag_cloud_count' );
    function show_tag_cloud_count( $return ) {
    $tags = explode('</a>', $return);
    $regex = "#(.*title[=]')(.*)( topic.*)#e";
    foreach( $tags as $tag ) {
    $tagn[] = preg_replace($regex, "('$1$2$3&nbsp($2)')", $tag );
    }
    $return = implode('</a>', $tagn);
    return $return;
    }
  10. WebsiteNewbie
    Member
    Posted 1 year ago #

    Thank you so much! I haven't tried the numbers yet as I'm thinking it might look better without, but you've helped me so much. Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic