Customizing Your Blog Posts with Template Tags

This section covers the template tags that you use to display the body of each blog post you publish. The body of a blog post includes information such as the post date and time, title, author name, category, and content. Table 12-3 lists the common template tags you can use for posts, available for you to use in any WordPress theme template. The tags in Table 12-3 work only if you place them within The Loop (covered earlier in this chapter and found in the loop.php template file).

Table 12-3

Template Tags for Blog Posts

Tag

Function

get_the_date();

Displays the date of the post.

get_the_time();

Displays the time of the post.

the_title();

Displays the title of the post.

BE*

Tag

Function

the_permalink();

Displays the permalink (URL) of the post.

get_the_author();

Displays the post author's name.

the_author_link();

Displays the URL of the post author's site.

the_content('Read

Displays the content of the post. (If you use an

More...');

excerpt [below], the words Read More appear

and are linked to the individual post page.)

the_excerpt();

Displays an excerpt (snippet) of the post.

the_category();

Displays the category (or categories) assigned

to the post. If the post is assigned to multiple

categories, they'll be separated by commas.

comments_popup_

Displays a link to the comments, along with the

link('No Comments',

comment count for the post in parentheses. (If

'Comment (1)',

no comments exist, it displays a No Comments

'Comments(%)');

message.)

next_posts_

Displays the words Previous Entries linked to

link('«

the previous page of blog entries.*

Previous Entries')

previous_posts_

Displays the words Next Entries linked to the

link('Next Entries

next page of blog entries.*

»')

* These two tags aren't like the others. You don't place these tags In The Loop; Instead, you Insert them after The Loop but before the if statement ends. Here's an example:

* These two tags aren't like the others. You don't place these tags In The Loop; Instead, you Insert them after The Loop but before the if statement ends. Here's an example:

<?php next_posts_link('&laquo; Previous Entries') ?> <?php previous_posts_link('Next Entries &raquo;') ?> <?php endif; ?>

WordPress Cash Machines

WordPress Cash Machines

In WordPress Cash Machines, you will learn over 50 different methods of making money with WordPress.

Get My Free Ebook


Post a comment