0

I want to add a function call in the single post page after the content, one way is that I add it in the single page template, eg.

<div id="content">
    <?php the_content(); ?>
    <?php my_function(); ?> 
</div>

However is it possible to do the above task automatically , using any filter etc so that I can include in a plugin or in the functions.php file?

2
1

You've already been pointed to the correct approach and the answer is functionally identical to any of the answers here about appending data to post content. All you need is something like:

function my_function () {
  echo 'my function content';
}
add_action('the_content','my_function');

To restrict that to single post pages:

function my_function () {
  if (is_single()) {
    echo 'my function content';
  }
}
add_action('the_content','my_function');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.