Last active
June 25, 2024 13:13
-
-
Save MHitMaN/594eefa239b0ac84c214c7ebb80937aa to your computer and use it in GitHub Desktop.
Edit before output (render) site content WordPress and modify content (Buffer) | Edit site content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* WordPress modifying the output before render or edit site content. | |
* | |
* Apply find and replace rules | |
* or you can make any modification before content going on to show users. | |
* | |
* It's simple, just paste this code on your Plugin/Theme functions. | |
*/ | |
function modify_buffer_ob_call( $buffer ) { | |
// Here you can change the HTML content | |
return $buffer; | |
} | |
function modify_buffer() { | |
ob_start(); | |
ob_start( 'modify_buffer_ob_call' ); | |
} | |
add_action( 'template_redirect', 'modify_buffer' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment