Problem: You need to change the text of something in WordPress but cannot figure out where to change it or it’s simply not possible to change it using the theme options.
The following code snippet will help you change any text dynamically using PHP.
- Copy the code snippet in functions.php
- Replace ‘ORIGINALTEXT’ by whatever text you want to change on your website.
- Finally replace ‘New Text’ by whatever you want and save.
- Important to note that the text you will replace is case sensitive
function start_modify_html() { ob_start(); } function end_modify_html() { $html = ob_get_clean(); $html = str_replace( 'ORIGINALTEXT', 'New Text', $html ); $html = str_replace( 'originaltext', 'New Text', $html ); echo $html; } add_action( 'wp_head', 'start_modify_html' ); add_action( 'wp_footer', 'end_modify_html' );