• Resolved Joerg

    (@yorck001)


    Hello.
    My client edits his site mostly by himself. He is using certain words frequently and wanted to have these words displayed in red by default.
    Using
    [function replace_text($text) {
    $text = str_replace(‘ausverkauft’, ‘<span style=”color: #ff0000;”>ausverkauft</span>’, $text);
    $text = str_replace(‘Achtung! Nur noch wenige Resttickets!’, ‘<span style=”color: #ff0000;”>Achtung! Nur noch wenige Resttickets!</span>’, $text);
    return $text;
    }]
    did the job so far. But not in a table like TablePress. What would be the proper syntax to have it work in TablePress as well?
    Any help is appreciated.
    Thanks.
    Joerg

    • This topic was modified 5 years ago by Joerg.
    • This topic was modified 5 years ago by Joerg.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    What are you applying the replace_text() function to? A filter hook like the_content? It would then probably not see the table content, but you can achieve that by also using

    add_filter( 'tablepress_table_output', 'replace_text' );
    

    e.g. in your theme’s “functions.php” file or wherever this function is defined.

    Regards,
    Tobias

    Thread Starter Joerg

    (@yorck001)

    Hi Tobias. Thanks for your prompt response. The add_filter function did the trick. Thanks again.
    Schoene Gruesse nach Magdeburg…:-)
    Joerg

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Color for defined text’ is closed to new replies.