Get entire post in variable

Wpsnipp – How to get entire post in variableVariables are one of the core powers of programming. Adding this PHP code to your functions.php file of your wordpress theme will place a entire page into a PHP variable.

 

 

<?
function callback($buffer) {
// modify buffer here, and then return the updated code
return $buffer;
}
function buffer_start() {
ob_start("callback");
}
function buffer_end() {
ob_end_flush();
}
add_action('wp_head', 'buffer_start');
add_action('wp_footer', 'buffer_end');
?>

Be Sociable, Share!

Leave a comment