Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add footers to the end of my posts. I need to be able to assign different footers to different posts (not globally).

I tried using WP Post Footer, but it's not working on WP 3.1.2.

share|improve this question
    
Can you clarify this a bit? Do you mean you have say five different footers, and for a post you want to choose one of these (or no) footer, which should be added to the end of the post? –  Jan Fabry May 4 '11 at 12:37
    
@Jan: That's exactly what I'm looking for. I was able to get WP Post Footer working... see answer below. –  Darren May 4 '11 at 14:00

4 Answers 4

Anything you add, inside the Loop, but after the call to either the_content() or the_excerpt(), will, in essence, be a Post "footer".

Say you have:

<div <?php post_class(); ?>
     <div class="post-header">
          <h1><?php the_title(); ?></h1>
     </div>
     <div class="post-entry">
          <?php the_content(); ?>
     </div>
</div>

You could do something like this:

<div <?php post_class(); ?>
     <div class="post-header">
          <h1><?php the_title(); ?></h1>
     </div>
     <div class="post-entry">
          <?php the_content(); ?>
     </div>
     <div class="post-footer">
          <p>Hello! I'm a Post Footer!</p>
     </div>
</div>

To give specific instruction, we'll need to know what Theme you're using.

share|improve this answer

Someone may have a more elegant solution, but if you're comfortable editing some of the template files, you can copy your footer.php and rename to footer-alt.php or whatever suits you. Make the changes you need, and in the template file you're using for the specific post-type, replace <?php get_footer(); ?> with <?php include("footer-alt.php"); ?>

If you keep the div and class names the same, you should not have any issues with the layout.

Cheers!

share|improve this answer
    
I think the OP is referring to footers for posts, rather than for the site as a whole? –  Chip Bennett May 3 '11 at 21:26
    
You could call the custom footer file from within the specific post template, thus the "include" vs "get_footer" -- again, maybe not the best solution, but it's worked for me. :) –  John May 3 '11 at 22:32
    
Rather than using include( 'footer-alt.php' ), use get_template_part() instead, e.g. get_template_part( 'footer', 'alt' ). Note: in order to avoid confusion, I would use a basename other than "footer", which has a specific meaning in the context of a WordPress Theme. –  Chip Bennett May 4 '11 at 14:10

Here is a quick solution for you:

on the page or post you want to add a post footer create a new custom field named post_footer and in the value add the footer content.

then paste this code in your theme's functions.php file

add_filter('the_content',`my_post_footer`,99);
function my_post_footer($content){
   global $post;
   $footer = get_post_meta($post->ID,'post_footer',true);
   if ($footer){
      return $content . $footer;
   }
   return $content
}

and you are done! This way you can have different footers on each page/post and none at all if you don't want it.

share|improve this answer

Was able to get WP Post Footer working. The online instructions at WP Plugin page is missing an instruction (found it in the readme in the zip pkg).

Need to add the following line to the Single.php module for the theme you are using:

<?php if (function_exists('wp_post_footer')) wp_post_footer(); ?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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