One way to give your WordPress blog a more personal touch is by adding a signature to the posts. So, here are two ways to automatically include a signature graphic to your blog posts, without installing an additional plugin.
Method 1:
Add the below code to your theme’s functions.php file:
function post_signature($sign) { global $post; if($post->post_type == 'post') $sign .= '<div class="signature"> <img src="" alt="signature" /> </div>'; return $sign; } add_filter('the_content','post_signature');
You can see that the signature is wrapped in a DIV. This helps in styling it with CSS, if required. For example:
div.signature img { float: right; padding: 5px; }
Method 2:
Another way to add a signature is by directly editing your theme’s template files.
For that, open index.php or single.php file with a text editor, and find a similar code:
<?php the_content(); ?>
Below this, add your signature:
<?php the_content(); ?> <?php if (is_single()) { echo '<div class="signature"> <img src="" alt="signature" /> </div>'; } ?>
Finally save the template file, and refresh blog to see result.
It’s recommend that your signature graphic be a transparent GIF or PNG file. Also make sure that it is no wider than the width of the content container of your WordPress Theme.
15 thoughts on “Add Signature to WordPress Posts without Installing a Plugin”
Good Tutorial :D. And I want ask, How to Add Signature to RSS Feed without Plugin?
This code will add your signature at the end of a post in feed:
If you prefer text, you can replace the <div> container with any text.
wow, great… I will try. thank’s @Renji 😀
Code for Feeds not work, Only show in FEEDS if the post have only short content. thank’s besofe.
It should work. Are you showing full content in your feed or just excerpt? If only excerpt, you will have to add another filter.
Add this at the very end of the earlier code:
Tell me if you need any further assistance.
how to place in homepage,?
I’m try with this code but not display..
help me..
thanks
Add this to your theme’s
functions.php
file:function post_signature($sign) { global $post; if(is_single() || is_home()) { $sign .= '<div class="signature"> <img src="http://site.com/path/to/signature.png" alt="signature" /> </div>'; return $sign; } } add_filter('the_content','post_signature');
Replace the highlighted section with anything you want.
I thought it is impossible, but great that signature is still possible by using codes only. I find it kinda hard because codes are a big NO to me. But thanks a lot. Great and helpful post.
Hi Shaina, Glad it helped. Even I prefer codes over plugins and that’s why I always share more useful codes here on SumTips than plugins.
Btw how is it that codes are great and a “big No” to you ? 😉
Hi Renji
this one is great..can i try this one?
is this codes work?
Hi Renjii
I have 3 other authors and my question is, is it possible to make it with a shortcode? So all the authors only need to make a “call” in back-end to get their own signature?
If not, thanks anyway for the nice code snippet.
Hi Karel,
Yes, you can do that. Create a function like this for each author:
Then at the end of a post, just enter
[author1_sign]
and you will get that author’s signature there.That is amasing…thank you so much Renji!!!
None of these methods worked for me. I either got errors or nothing showed up.
It works for me, but it goes to the bottom of all my share’s and “you might like” pages. I would like it to be on the bottom of the written post I make.
Is there a code to make it go below the post, and not all the extra content? Example of the content can be seen on this page: http://ssimplyme.com/2012/03/12/foam-soap-2/
I manually put the sig right now, and that’s the area I want it to be auto, is there a way to do that? 🙂 Thank you for posting this info, regardless of where the sig is, it’s nice! 🙂 😀