Hi!
For modifying the content of certain static pages on the fly, can you help me understand the difference between using a GP hook like generate_before_content to modify the content vs using a code snippet like the one below. For example, let’s say I want to modify the content of some reusable blocks on the fly.
<?php
/**
* Replace Text in post content
**/
function vr_replace_content($content) {
$find = array('One', 'Two', 'Three'); // The items to replace
$replace = array('Uno', 'Dos', 'Tres'); // Their replacements
$content = str_replace($find, $replace, $content); // $finds strings in the $content to $replace
return $content; // The filtered content
}
add_filter('the_content','vr_replace_content'); // This injects vr_replace_content() into the filter the_content(). The normal output of the_content() is altered by the custom function vr_replace_content()
(Above example copied from https://journalxtra.com/wordpress/snippets/edit-wordpress-page-source-on-the-fly/)
Just trying to understand how to know which approach is better/faster/more stable to use.
Thanks!