How to Customize Your WordPress Blog Posts with Template Tags

The body of a WordPress blog post includes information such as the post date and time, title, author name, category, and content. These common tags work only if you place them within The Loop (which is found in the loop.php template file).

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.
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 More...’); Displays the full content of the post.
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’re separated by commas.
comments_popup_link('No Comments', 'Comment (1)', 'Comments(%)'); Displays a link to the comments, along with the comment count for the post in parentheses. (If no comments exist, a No Comments message displays.)
next_posts_link('« Previous Entries') Displays a Previous Entries link that links to the previous page of blog entries.
previous_posts_link('Next Entries »') Displays the Next Entries link that links to the next page of blog entries.

The last two tags in the table 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 endwhile; ?>
<?php next_posts_link('&laquo; Previous Entries') ?>
<?php previous_posts_link('Next Entries &raquo;') ?>
<?php endif; ?>
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com