Title: How to replace string on HTML output?
Last modified: July 20, 2020

---

# How to replace string on HTML output?

 *  [brandontan903](https://wordpress.org/support/users/brandontan903/)
 * (@brandontan903)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/how-to-replace-string-on-html-output/)
 * If WP Super Cache caching disabled, I can replace without problem.
 * But when caching enabled, no replace happen.
 * Below is my functions:
 *     ```
       if (!is_admin()) {
               function letsdoreplace($buffer) {
                   $toreplace = array(
                       "giraffe",                                                                 // Regular CSS
                       "rabbit",
                   );
                   $withtext = array(
                       "giraffe and friends",                                                                    // Regular CSS
                       "elephant and rabbit",
                   );
                   return (str_replace($toreplace, $withtext, $buffer));
               }
               ob_start("letsdoreplace");
       };
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/how-to-replace-string-on-html-output/#post-13147120)
 * You’ll need to enable dynamic caching in the plugin and write a plugin to do 
   the str_replace there.
    Look in this post for details but unfortunately it’s 
   complicated. [https://odd.blog/2013/10/21/shiny-new-dynamic-content-wp-super-cache/](https://odd.blog/2013/10/21/shiny-new-dynamic-content-wp-super-cache/)

Viewing 1 replies (of 1 total)

The topic ‘How to replace string on HTML output?’ is closed to new replies.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/how-to-replace-string-on-html-output/#post-13147120)
 * Status: not resolved