Support » Plugins » Function to style certain characters?

  • Is there a plugin or a function to make certain characters for example make the letter A bold or green?
    I tried out an old code I found on the net but it didn’t work out too well. :/

Viewing 1 replies (of 1 total)
  • catacaustic

    (@catacaustic)

    very awesome

    You could try adding your own code… I don’t know of a plugin that will do what you’re after (but I haven’t had an exhaustive look).

    add_filter ('the_content', 'my_format_function');
    
    function my_format_function ($content) {
        $search = array (
            "A",
            "B"
        );
    
        $replace = array (
            "<span style='color: green;'>A</span>",
            "<span style='color: red;'>B</span>"
        );
    
        $content = str_replace ($search, $replace, $content);
    
        return $content;
    }

    The big thing to remember is that it will replace every instance of ‘A’ and ‘B’ no matter where it is in teh content, so I’d use it sparingly because it would be easy to get some unexpected results.

Viewing 1 replies (of 1 total)
  • The topic ‘Function to style certain characters?’ is closed to new replies.