How To Display Some Content at Just Home Page and Single Post of Blog

by Hiroshi on November 30, 2008

in Hacks, WordPress

Recently I wanted to display little about section me at my blog but just at home page and single post under sidebar. So how we can tell that we are at home page or at single post in case of WordPress Blog? Here is the code:

<?php if ( is_front_page() or is_home() or is_single() ) { ?>
Your content goes here.
<? } ?>

is_front_page() and is_home() both will server same purpose.
Put this code anywhere in your blog containing some content in the middle and it should display that content when just single post is viewed or home page of blog is being viewed.

Related Posts

Previous post:

Next post: