• Good Evening,

    I’m hoping this is an easy thing someone can help me with.

    I want to have all instances of my blog’s name appear bold and green. I’m not talking about in the header or footer as a logo or graphic, but in text throughout my blog, I mention my blog by name. I know how to set the text attributes so it comes out bold and colored, but I’m looking for a way to tell WordPress every time you see <my blog name> change it automatically to bold and green.

    I used to have a plug in years ago that would automatically convert specific words to a hyperlink (so every time I wrote “wordpress,” it would automatically change “wordpress” to <a href=https://www.www.remarpro.com>wordpress</a>. Is there a way to do the same thing (preferably without a plugin) to have it automatically change “my blog” to <b><style="color:green;">my blog</style></b>?

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You can use the ‘the_content’ filter.

    As a very untested example…

    function highlight_word ($content) {
        return str_replace ('My Blog title', '<span class="my-blog-title">My Blog title</span>', $content);
    }
    
    add_filter ('the_content', 'hightlight_word');
    Thread Starter Josh

    (@joshmbuck)

    @catacaustic, thanks for the response. Sadly, it did not work…and not only that, but it broke my site…when I tried to view a post using this, I just got a blank screen ??

    All good… I’ll keep tinkering.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘styling specific recurring words’ is closed to new replies.