I am looking for a proper way to hook into
method in Wordpress. Wordpress provide hooks for
,
and
but not for
. I have a plugin which I maintain that appends and prepends some HTML in the content post.
I used the same for
and
. What should I do to support
as well as I see most themes now use
? ie.: if the theme is using
instead of
, my plugin fails.
My plugin code is the following:
The above code (in my plugin) listens to
from the theme and add my own content to the article.
Assume this is the method in a theme file:
It works properly in the above case.
But if the theme code is something like this (Note the change from the_content() to
.
My plugin fails as there is no hooks defined for
. As I am not in control of theme code, the solution which Wordpress explains in the <a href="http://codex.wordpress.org/Function_Reference/get_the_content" rel="nofollow">documentation</a> doesn't help for me:
Update: Problem definition expanded for clarity.
Code:
get_the_content
Code:
the_content
Code:
the_excerpt()
Code:
get_the_excerpt()
Code:
get_the_content()
I used the same for
Code:
the_excerpt()
Code:
get_the_excerpt()
Code:
get_the_content()
Code:
get_the_content()
Code:
get_the_content()
Code:
the_content()
My plugin code is the following:
Code:
add_action('init', 'my_init');
function my_init() {
add_filter('the_content', 'my_method', 12);
add_filter('get_the_content', 'my_method', 12);
}
function my_method($content) {
$content = "blah blah".$content."blah blah";
return $content;
}
The above code (in my plugin) listens to
Code:
the_content call
Assume this is the method in a theme file:
Code:
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
</div><!-- .entry-content -->
It works properly in the above case.
But if the theme code is something like this (Note the change from the_content() to
Code:
get_the_content())
Code:
<div class="entry-content">
<?php echo get_the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
</div><!-- .entry-content -->
My plugin fails as there is no hooks defined for
Code:
get_the_content
Code:
<?php apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file )) ?>
Update: Problem definition expanded for clarity.