How to modify the output of any WordPress shortcode

Assume we have some plugin called AAA and it has built-in shortcode aaa_content and its usage is like this:

[AAA_content title=”Recent news” id=”23″]

Now we want to change its output HTML.

In WordPress, the output of any 3rd party function can be changed only if it has apply_filters() filtered output. Unfortunately not all functions and shortcodes have such filter in output. So it is almost impossible to modify its output without editing the plugin’s source file.

And as we know, editing the plugin file is always bad idea. The changes will be erased just in the next update.

So we have some different approach for such cases.

For example, here is one idea, which is subject of this blog post.

Creating parent shortcode which handles the output of the original shortcode.

So let’s declare and build that alternative shortcode.

Continue reading “How to modify the output of any WordPress shortcode”