0

How can we add # before each tag with both the_tags( ) and wp_tag_cloud( )?

  • Note: We need this, because without a hash a tag is worthless.. :) – Nicolai Jul 21 '15 at 15:59
3

Another very simple solution is to put this in your css file :

.tagcloud a:before {
  content: "#";
  font-color: #000;
}
1

You will have to use your own custom function, the_tags( ) doesn't allow you to do that. You could create a function like this, using get_the_tags, and format your html as you prefer :

function hashtags() {
    $posttags = get_the_tags();
    if ($posttags) {
        foreach($posttags as $tag) {
            echo '<a href="' . get_tag_link($tag->term_id) . '">#' . $tag->name . '</a> '; 
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.