Add ‘#’ beside each wordpress tag

I’m trying to add hashtags beside my post tags in WordPress.

With this code, it looks like : tag1, tag2, tag3

Read More
<?php the_tags( '<span class="meta-sep"> | </span><span class="tag-links">' . __( '', 'portfoliopress' ) . '</span>', ', ', '' ); ?>

But I’d like to change it to : #tag1, #tag2, #tag3

I tried to add # into this part

‘, ‘, ‘, ” ); ?>

but it gave me a fatal error. I don’t know PHP, but it seems like a simple task. Am I looking in the wrong place?

Related posts

Leave a Reply

1 comment

  1. <?php the_tags( '#', ', #', '' ); ?>
    

    EDIT: to add the # to the link text:

    if( $tags = get_the_tags() ) {
        echo '<span class="meta-sep"> | </span>';
        foreach( $tags as $tag ) {
            $sep = ( $tag === end( $tags ) ) ? '' : ', ';
            echo '<a href="' . get_term_link( $tag, $tag->taxonomy ) . '">#' . $tag->name . '</a>' . $sep;
        }
    }