The WordPress Plugin API is a fantastic way for third-party scripts to be able to inject themselves into the WordPress lifecycle; want to change the output of the post content? Simply attach a callback to the the_content
filter:
/** * Inject a cat emoji at the end of the post content. * * @param string $content The post content. * @return string The filtered post content. */ function inject_cat_emoji( $content ) { return $content .= ' ?'; } add_filter( 'the_content', 'inject_cat_emoji' );
Now, whenever content is run through the the_content
filter, our “?” will be appended.