I am not really looking for code as answer but just the idea.

How can i replace content in posts or pages without using short codes or plugins via the recent rest API? In template engines you'd have variable place holders filled later by whatever but I'd like to get exactly around writing extra wp code (short codes, hooking into events, etc...)

However, I can't obviously just drop my custom markup in the content because it would be displayed to users as well. Eventually there is a trick over CSS but I'd love to hear the experts first.

thanks a lot, g


You can use filter for replace text in all post and all pages. add this code to theme function.php

add_filter( 'the_content', 'filter_content_for_replace_text' );
function filter_content_for_replace_text($content){
    $content=str_replace("find","replace with",$content);
    return $content;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.