|
Helping ordinary people create extraordinary websites! |
WordPress CustomizationBy Justin Laing2008-01-09
Blog / Post Templates
<?php get_header(); This just calls your header.php
template. It’s nice to use your header.php file to display all the
common header HTML code for all your pages. That way you can avoid
writing the same <head>…</head> and beginning <body>…
content over and over.
<div id=”content” Here is where we start “The Loop”. In
WordPress each page normally has a “loop” on it that cycles through the
content that should be displayed on that page. In our single.php
template there would normally just be one “post”, which means the loop
would just execute once to display that one post. The if (have_posts()) code first checks to see if we have a post to display, then the while (have_posts()) loops through each of the posts, the_post(); simply
prepares the post for display. Most pages will have this same loop code
on them. WordPress takes care of deciding what posts should go on which
pages in most instances. Occasionally you’ll want to customize what
posts are displayed within the loop, but we’ll cover that in a second.
<div Here the template is laying out some
basic navigation that allows the user to move between blog posts. The
previous_post_link() function places a <a href=”..”> tag that if
clicked will navigate the user to the previous post in the blog. The
next_post_link() is very similar.
<div
This code displays the actual post content (the content that you created under the “Writing” tab in the admin interface). The the_content(); function
displays the HTML for the current “post” within “The Loop”. The
argument within the function “…Read the rest of this entry…” is text
that will be displayed in a <a href></a> tag at the end of
the content if the content spans more than one page.
So how do I add some author information and maybe date of the post to this? <p>This post was written by <?php the_author(); ?></p>
Now to put the date the post was written we could put: Tutorial Pages: » Introduction To WordPress » WordPress Themes » Structure Of A WordPress Theme » Making Your New Theme » Modifying The Header » Blog / Post Templates » The Post Loop » Page Templates » Sidebars » Meta Data / Custom Fields For Page Customization Originally posted on Makebeta |
|