How to display post title outside loop

In some cases you need to display your post title outside your loop. If you want to display the post title within the loop then its easy you can use <?php echo get_the_title(); ?> or <?php  the_title(); ?>

Use following function to display your post title outside loop.

<?php single_post_title( $prefix, $display ); ?>

Where $prefix is text to place before title. and $display is Boolean, if set to TRUE then title is displayed , and set to FALSE then it is returned for use in PHP

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s