Wondering how to add a hash symbol (#) before each of your tags? Read on!
Filters are a type of hook in WordPress that allow you to modify data. In this case, you will need to create a filter that modifies tag output when a post is rendered.
The first step is to create a callback function that, when given a list of tags, replaces the relevant HTML to include a hash symbol before tag instances. The function must then return the modified list.
Next, all you have to do is register your new function with the tags hook.
Try it yourself, add the following code to the bottom of your functions.php file:
function filter_post_hashtag($list) {
$list = str_replace(‘rel=“tag”>’, ‘rel=“tag”>#’, $list);
return $list;
}
add_filter( ‘the_tags’, ‘filter_post_hashtag’ );