Skip to content

Instantly share code, notes, and snippets.

@MHitMaN
Last active June 25, 2024 13:13
Show Gist options
  • Save MHitMaN/594eefa239b0ac84c214c7ebb80937aa to your computer and use it in GitHub Desktop.
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
<?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