I’m writing a plugin that requires adding to the content; adding a filter to the_content() is straightforward enough, but the theme I’m testing in uses get_the_content() to build the page.
There’s an indication that it should be possible in the WordPress codex but I don’t understand the example:
If you use plugins that filter content (add_filter(‘the_content’)), then this will not apply the filters, unless you call it this way (using apply_filters):
apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file ))
Can anyone help / explain?
Thanks,
David.
What they’re saying is you’d have to add code to the place that
get_the_content()
is called. From your description, that’s in the theme – you’d have to change the theme’sget_the_content()
call as described.The reason for that is that there are no filters in the
get_the_content()
function that you can hook into with your plugin (have a look at the source – there are no calls to theapply_filters()
function inget_the_content()
, except one for the “more” link text).Late to the party, but here it goes:
In your functions.php you can add something like this:
Next, in your page.php (or whichever template you want to use it in) you can call the raw content with the same filter as following: