I am creating a WordPress Plugin for WordPress directory.

How can I get the_content() after applying all the shortcodes that are presents in the_content?

Let me explain:

My plugin will be used in multiple themes and websites; and users will add some shortcodes in their posts or pages. I want my plugin to work after these shortcodes are parsed, and then use the content for my plugin as input.

2 Answers
2

Are you looking for a filter perhaps?

add_filter( 'the_content', 'wpse_the_content_filter', 20 );

function wpse_the_content_filter( $content ) {
   // Do whatever you want with the $content
   return $content;
}

Filtering ‘the_content’ will pass the post or page content through a function of your choice.

Just make sure to run it late (e.g. 20) and return the contents so they can be displayed.

More information here:

https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content

Leave a Reply

Your email address will not be published. Required fields are marked *