WordPress.org

Support

Support » How-To and Troubleshooting » How to customize widget Tag Cloud

How to customize widget Tag Cloud

Viewing 15 replies - 1 through 15 (of 20 total)
  • Tara
    Participant

    @t-p

    Michael
    Forum Moderator

    @alchymyth

    you could work with a filter function;
    http://codex.wordpress.org/Plugin_API/Filter_Reference

    example:

    add_filter ( 'wp_tag_cloud', 'tag_cloud_count' );
    function 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&nbsp;Poster'.(($2!=1)?'a':'').')')", $tag );
    }
    $return = implode('</a>', $tagn);
    return $return;
    }

    engl version:

    add_filter ( 'wp_tag_cloud', 'tag_cloud_count' );
    function 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&nbsp;post'.(($2!=1)?'s':'').')')", $tag );
    }
    $return = implode('</a>', $tagn);
    return $return;
    }

    Bojan Denic
    Participant

    @evilmc

    @alchymyth, can you tell me where should I put this code?

    Sorry for my english.

    Michael
    Forum Moderator

    @alchymyth

    forgot to say – the code belongs into functions.php of your theme.

    Bojan Denic
    Participant

    @evilmc

    @alchymyth, I add this code into my theme, but nothing changed, everything remains the same.

    I use this code:

    add_filter ( 'wp_tag_cloud', 'tag_cloud_count' );
    function 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&nbsp;post'.(($2!=1)?'s':'').')')", $tag );
    }
    $return = implode('</a>', $tagn);
    return $return;
    }

    Michael
    Forum Moderator

    @alchymyth

    maybe because of the language –

    this is the html code of one tag within the tag cloud (english site):

    <a href='http://localhost/wordpress/keywords/articles/' class='tag-link-110' title='2 topics' style='font-size: 14.3pt;'>articles</a>

    try to see what this word is in your language:

    topic

    and then edit the filter code accordingly.
    can you post a link to your site?

    Bojan Denic
    Participant

    @evilmc

    Yes, this is my website: http://www.lajkuj.rs/

    And I use this permalinks: http://i39.tinypic.com/1tspjc.jpg

    Tara
    Participant

    @t-p

    i tested the English version and it works fine for me.

    Michael
    Forum Moderator

    @alchymyth

    @evilmc – I see, it is (partly) working;

    try to change the one line in the code to:

    $regex = "#(.*title[=]')(.*)( tem.*)#e";

    if you don’t see it in your browser, try to clear the browser cache – reload the web page or try pressing ‘CTRL F5’

    Bojan Denic
    Participant

    @evilmc

    @alchymyth, now works!

    big thanx! 🙂

    Bojan Denic
    Participant

    @evilmc

    @alchymyth, can you tell me what to delete, shows only the numbers (don’t show Poster).

    Thanx

    Michael
    Forum Moderator

    @alchymyth

    this is what I see: http://imageshack.us/photo/my-images/41/posteram.jpg/

    have you tried to clear the browser cache or re-loaded the web page?

    if you still only see the numbers, please past the full code of the filter function ( see http://codex.wordpress.org/Forum_Welcome#Posting_Code )

    Bojan Denic
    Participant

    @evilmc

    Yes, yes…and works! I crear my browser cache, but now I won’t show only numbers tags, don’t show title(poster-a).

    Michael
    Forum Moderator

    @alchymyth

    ok, I get it –

    change the filter function to:

    add_filter ( 'wp_tag_cloud', 'tag_cloud_count' );
    function tag_cloud_count( $return ) {
    $tags = explode('</a>', $return);
    $regex = "#(.*title[=]')(.*)( tem.*)#e";
    foreach( $tags as $tag ) {
    $tagn[] = preg_replace($regex, "('$1$2$3&nbsp($2)')", $tag );
    }
    $return = implode('</a>', $tagn);
    return $return;
    }
    Bojan Denic
    Participant

    @evilmc

    I get this error:
    Parse error:
    syntax error, unexpected ';', expecting T_PAAMAYIM_NEKUDOTAYIM in /home/www/lajkuj.rs/wp-content/themes/BlueMotion/functions.php on line 306

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘How to customize widget Tag Cloud’ is closed to new replies.