QNimate

  • CoursesVideos
  • WP PremiumPlugins
  • DemosLab
  • Home
  • QIdea
  • QTrack
Home Carbon Ads WordPress Filter Final HTML Output

WordPress Filter Final HTML Output

Here is the code to to filter the final HTML output in WordPress.

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_loaded', 'buffer_start');
add_action('shutdown', 'buffer_end');

One of the use case of this is when you want to add “nofollow” rel to all links pointing to external websites.

Jan 16, 2015Narayan Prusty
Create a Feed Reader App using Intel XDKHow to check if someone copied my website

Leave a Reply Cancel reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Narayan Prusty

I am a software engineer specialising in Blockchain, DevOps and Go/JavaScript. This is my personal blog where I write about things that I learn and feel interesting to share.

8 years ago WordPress
Share this
0
GooglePlus
0
Facebook
0
Twitter
0
Linkedin
Related Articles
  • Change WordPress Default Avatar
  • WordPress Enable Automatic Plugin Updates
  • WordPress Enable Automatic Theme Updates
  • WordPress Set Visual Editor as Default
  • WordPress Set HTML Editor as Default
Our Sponsor
My Books

2014 - 2015 © QNimate
All tutorials MIT license