0

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

1 Answer 1

1

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;
}
1
  • But what about replacing a specific post (or comment) using the API? Commented Aug 10, 2022 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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