Forums

Add Separator in wp_tag_cloud (4 posts)

  1. Trafficx
    Member
    Posted 2 years ago #

    How add "separator" in wp_tag_cloud?

    I need this "|".

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    call the wp_tag_cloud directly, and then use either:
    http://codex.wordpress.org/Template_Tags/wp_tag_cloud#Parameters

    separator
    (string) (optional) The text/space between tags. Note: this parameter was introduced with Version 2.9.
    Default: '/n' (whitespace)

    or:

    <?php $tag_cloud=wp_tag_cloud('smallest=8&largest=18&format=array');
    foreach($tag_cloud as $tags) :
    echo $tags.' | ';
    endforeach; ?>
  3. Trafficx
    Member
    Posted 2 years ago #

    I try call the wp_tag_cloud directly, and then use this parameter, but not work.

    Can we change the parameter?
    For example:
    <?php wp_tag_cloud('smallest=12&largest=12&unit=px&separator=|'); ?>
    This code not work.

    Codex says: The text/space between tags

    This

    <?php $tag_cloud=wp_tag_cloud('smallest=8&largest=18&format=array');
    foreach($tag_cloud as $tags) :
    echo $tags.' | ';
    endforeach; ?>

    Work fine. Thanks

  4. Moodles
    Member
    Posted 2 years ago #

    The 2nd way to show the tags was was helpful. I was looking for a way to use ASCII code for my separator, like this:

    <?php $tag_cloud=wp_tag_cloud('smallest=10&largest=20&format=array');
    foreach($tag_cloud as $tags) :
    echo $tags.' · ';
    endforeach; ?>

    EDIT: this line echo $tags.' · '; is this, without the spaces:
    `echo $tags.' & # 1 8 3 ; ';

Topic Closed

This topic has been closed to new replies.

About this Topic