For a blog, one of the most important pieces of content that you can display is a post's title. The title should be interesting; it should grab attention, it should provide great linking material, and it should make your readers want more. In this recipe, we'll start talking about template tags by describing how you would display a post's title.
First, open a template file for your theme that contains a variation on The Loop. You can learn more about The Loop in Chapter 3. As a reminder, it looks something like this:
<?php if(have_posts()) { while(have_posts()) { // Display content here } }
Inside of your instance of The Loop, insert the following code, in order to display each post's title:
<?php the_title(); ?>
To see this in action, you can refer back to the recipe Creating a basic Loop
. There you used the_title
inside of The Loop, successfully displaying the title of each of the posts.