Several of my posts in the same category have the same footer. I figured it would be much more maintainable if I could move this into a separate location and manage it from a central place.

How can this be achieved? Is there a plugin that I could reference?

  • I have not tried anything beyond searching for plugins. There is no code for me to show.
    – MxLDevs
    Oct 20, 2014 at 17:27
  • You could place the code in a separate PHP file and require it from single.php - require get_template_directory() . '/single-footer.php'; Then do an IF statement to check the category in this file with something like get_the_category()[0]->term_id; and decide what text to show. This means that if you ever decide to change the text you only have to change single-footer.php and the change will show in ALL posts falling under the specified category. This also means there is no need to paste the footer text in each and every one of your posts, hence less database space.
    – WPRookie82
    Oct 20, 2014 at 17:34

1 Answer 1


I would suggest a filter on the_content much like:

function conditional_footer_wpse_165930() {
  if (is_single()) {
   if (has_category('cat')) {
      return 'This is the cat footer';

I am not sure about all of the details you require. You may need to tweak that code.

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.