WordPress – add content filter after shortcode execution

Sometimes we need to add content filter in wordpress which should execute after all the shortcodes. The shortcodes in wordpress are executed by filter do_shortcode at priority 11. Here is code snippet from wp-includes/default-filters.php

// Shortcodes
add_filter( 'the_content', 'do_shortcode', 11 );

To add a filter to the_content, one can add filter with priority 12 or higher. Here is sample content filter code snippet.
add_filter('the_content', 'my_content_filter', 12);
function my_content_filter($content) {
  // Do custom processing on $content
  return $content;
}

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments