I had this idea to introduce a 'post type footer' using Advanced Custom Fields so that my users could set up common, reusable messages or calls to action and have them appear after the content of a specific post type. This works great on my native post types as I can simply filter the_content but doesn't work on post types that don't employ this hook, like WooCommerce 'products' for example.

Can anyone recommend a way in which I could hook into all post types via a single hook without editing templates?

I should mention as well that I'm attempting to make this applicable to post types that might be added later by the client, which is why I can't make changes to the post type templates directly. To this end also, my admin section gets the active post types of that particular environment.


1 Answer 1


All I can think is to process the posts at an earlier stage with a Core hook. This is crude, of course, but:

function hack_the_post($posts) {
  foreach ($posts as $p) {
    $p->post_content .= ' I added this';
  return $posts;
add_action('the_posts', 'hack_the_post');

It is a bit energy intensive but so long as your plugin/theme uses more or less standard core functions it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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