How to Add a Signature to Your WordPress Posts

Adding a signature to your WordPress posts is one way to give your blog a more personal touch. The code below will automatically include your signature after the content of your blog posts so that you don’t have to manually add it every time. Here’s an example result:

Copy this code and paste it into your functions.php file:

1
2
3
4
5
6
7
8
add_filter('the_content','add_signature');
function add_signature($text) {
global $post;
if($post->post_type == 'post') $text .= '<div class="signature">
<img src="http:/yoursite.com/wp-content/themes/yourtheme/images/signature.png" alt="signature" />
</div>';
return $text;
}

Make sure to change the image URL to the location of your image, or you can replace the image tag with plain text.

Tweak via CSS as needed…

If you have any issues with the placement or appearance of your signature, you can style it with CSS. For example:

1
2
3
div.signature img {
padding: 5px;
}

The best part is that there’s no need to add a new plugin to accomplish this. Simply copy and paste and your signature will be automatically included. Update the image any time you like and it will be dynamically changed on all posts on your blog.

Tags

Comments (18)

  1. Hi Sarah,

    This is a cool tip! I’ve always done it manually with an image. Good to know I can add it to my code. Hmmm… I wonder how it’s going to work out when I have a guest poster on my site??? I guess no way of taking it out for individual posts huh?

    Thanks again! :-)

  2. This is a great tip, and I am using it on my site. The problem I’m having is that it squishes my signature and it doesn’t look as good as it does in Photoshop. Is there another line I can put in the code to make sure it retains it’s original width? I tried adding width=”288px” but that didn’t help.

    Thanks

  3. Hi Sarah! Loved your tip, it worked perfectly, but I’d like to know if there’s a way to edit this code so my signature appears only on the post page. I have excerpts on the main page and I don’t want to show up my signature below it. Hope you can help me! Thank you!

Participate