Title: Replace with HTML
Last modified: August 8, 2018

---

# Replace with HTML

 *  Resolved [thierrybeauchemin](https://wordpress.org/support/users/thierrybeauchemin/)
 * (@thierrybeauchemin)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/replace-with-html/)
 * Hi,
    I’m struggling to make an easy Replace. I would like to add an extra span
   around a word.It’s a staight forward replacement, no placeholder, no multiple
   instance, nothing like that.
 * Find: myWORD
    Replace: <span class=”myClass”>myWORD</span>
 * My problem is the quotation mark which screw everything and also the space between“
   span” and “class”. I’m trying with adding some \ in front but nothing seem to
   work.
 * Any help would be appreciated 🙂

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Marios Alexandrou](https://wordpress.org/support/users/marios-alexandrou/)
 * (@marios-alexandrou)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/replace-with-html/#post-10573307)
 * That should work fine. I’m not sure what issue you’re describing. You’re NOT 
   trying to use regex, correct?
 *  Thread Starter [thierrybeauchemin](https://wordpress.org/support/users/thierrybeauchemin/)
 * (@thierrybeauchemin)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/replace-with-html/#post-10573317)
 * Exactly, no regex nothing… but I beleive I found the problem.
 * What happens is Space are converted to “`&nbsp;`” and quotation mark are being
   removed. I think it have to do with WordPress doing something AFTER your plugin,
   could it be the case ?
 * [https://stackoverflow.com/questions/5940854/disable-automatic-formatting-inside-wordpress-shortcodes](https://stackoverflow.com/questions/5940854/disable-automatic-formatting-inside-wordpress-shortcodes)
 * Could wordpress be formating the “Replace text” after your hook ?
    If so, could
   I place your code AFTER the wpautop ?
 * Thank for the help, really appreciated 🙂
    -  This reply was modified 7 years, 10 months ago by [thierrybeauchemin](https://wordpress.org/support/users/thierrybeauchemin/).
 *  Plugin Author [Marios Alexandrou](https://wordpress.org/support/users/marios-alexandrou/)
 * (@marios-alexandrou)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/replace-with-html/#post-10573336)
 * The plugin has been designed to be the last thing that runs i.e. after plugins,
   themes, etc. So I can’t see additional formatting being applied after my plugin.
   The only exception are caching plugins which are still able to cache pages modified
   by my plugin and deliver those cached pages.
 * Have you tried building the rule in pieces? For example, replace myword with 
   >myword< and if that works add more and more to the span tag until something 
   stops working. It might provide a clue as to the problem.
 *  Thread Starter [thierrybeauchemin](https://wordpress.org/support/users/thierrybeauchemin/)
 * (@thierrybeauchemin)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/replace-with-html/#post-10573353)
 * Caching is disable right now, but good to know 🙂
 * Ok, I found the problem by doing 2 test:
 * **Test 1**:search myWORD | replace potato
    myWORD present in main Content and
   also Footer _Works perfectly_
 * **Test 2**: search myWORD | replace “potato” (WITH quotation)
    myWORD present
   in main Content and also Footer _myWORD in Content is replace with quotation 
   myWORD in the footer is MISSING (not even present in the source code).
 * I’m using Elementor Pro to create the footer (I guess it inject it at some point).
   I strongly suspect that somehow Elementor FOOTER “retouch” your code. as it works
   perfectly with the main content (also created with elementor, just not injected).
   Not sure how to progress next…
 *  Thread Starter [thierrybeauchemin](https://wordpress.org/support/users/thierrybeauchemin/)
 * (@thierrybeauchemin)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/replace-with-html/#post-10573420)
 * Ok, just to inform. If I use Quotation mark in the replace field I cannot edit
   the page with Elementor (It’s stuck on loading with the big E).
 * So I guess you something in this plugin break Elementor if quotation are used.
 *  Plugin Author [Marios Alexandrou](https://wordpress.org/support/users/marios-alexandrou/)
 * (@marios-alexandrou)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/replace-with-html/#post-10573461)
 * Thanks for letting me know. I use quotation marks in my rules all the time so
   perhaps there is something special with the Elementor theme.
 *  Thread Starter [thierrybeauchemin](https://wordpress.org/support/users/thierrybeauchemin/)
 * (@thierrybeauchemin)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/replace-with-html/#post-10573549)
 * I’ve done a bit further test, and it really point to “where” this plugin is searching:
 * I’ve added a str_replace in my function.php and it works flawlessly in the $content
   section, but it cannot catch the footer. I’ve also found code that use $buffer(
   trying to catch the final HTML), but this also didn’t work (while working perfectly
   in the $content section).
 * So it’s either a question of “Region” (not sure if it’s the right wp term)
    or
   Elementor is being called at the end bypassing everything…
 * Hope this can help if others have the problem, thank for the support 🙂
    Awesome
   plugin BTW
 *  Plugin Author [Marios Alexandrou](https://wordpress.org/support/users/marios-alexandrou/)
 * (@marios-alexandrou)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/replace-with-html/#post-10574604)
 * Thank you for the additional information. This is the first theme that has shown
   this behavior. Are you using the free version of theme? If so, I’ll have to try
   it out.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Replace with HTML’ is closed to new replies.

 * ![](https://ps.w.org/real-time-find-and-replace/assets/icon-256x256.png?rev=1347950)
 * [Real-Time Find and Replace](https://wordpress.org/plugins/real-time-find-and-replace/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/real-time-find-and-replace/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/real-time-find-and-replace/)
 * [Active Topics](https://wordpress.org/support/plugin/real-time-find-and-replace/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/real-time-find-and-replace/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/real-time-find-and-replace/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Marios Alexandrou](https://wordpress.org/support/users/marios-alexandrou/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/replace-with-html/#post-10574604)
 * Status: resolved