There are many reasons that you might want to add things to the end of every single post. For example, you might want to add an author’s info box, a little blurb about your email newsletter or RSS feed, or you may just want to display an ad after your content.
Whatever the reason, it’s much simpler than you think. There’s two ways of doing it; the passable way and the best way. Obviously, i’m only going to discuss the best way in detail, but if you wanted to do it the passable way, you just need to edit your theme’s single.php file and insert whatever code you want to display below the loop. It has the downside of being overwritten when you upgrade your theme and not being transferrable to other themes automatically, which is why I recommend the better way.
The best way
As with most things in WordPress, the best way to achieve this is to create a small function and put it into your functionality plugin. In this example, I’m going to add a box after the content advertising my newsletter, but I’m going to include a conditional statement so that it is only displayed when viewing a single blog post (i.e. it won’t appear in archives or the RSS feed).
Here’s the code that you need to work with:
As you can see, the piece you need to be concerned with is between the two single quotes. This is where you can put whatever you want to appear at the end of your posts. You can use PHP if you need to by opening and closing the PHP tags multiple times. For example, the snippet below switches several times between PHP markup and HTML markup:
Be creative! What have you used this little trick for?