Let's break this down line by line"
$this_page_comment = $_GET['p'];
$this_page = $_GET['paged'];
Here I'm checking the URL to see if someone is requesting to see a specific page number or a specific post. Without this ability you won't be able
to do next page or add comments easily. Now that we have this information we're going to ask WordPress to hand us the information we want.
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$this_page_post_count = 0;
So we make one of three queries. We either ask for a specific post, a specific page, or just all the information. I'm asking for category 9 only in
this case. If you leave that out you'll get all information. So "query_posts()" would return everything. In the same manner query_posts(-9) would
return everything but the items in categtory 9. This is all fairly simple unless you want to filter out more than one category. Sadly you can't
filter out more than one category. Insted you have to ask for every category except for the few you don't want to see. I haven't had to do that yet,
and hopefully you won't either.
You can do more fun things like filter by year and month. "query_posts(&year=2007&monthnum=2)". I dont' remember every single possiblity, but the
odds are that if you want to do it, someone has done it before.
if (have_posts()) : while (have_posts()) : the_post();
This is the main loop for all WordPress pages.
A plugin I'm using. Exclude this line.
$this_page_post_count = $this_page_post_count + 1;
I'm keeping track of entries and later you'll see that I'm stopping once I get to 10. My way of showing only 10 items at a time.
Now we're in a specific post so I get the post date and title for display. I add in an edit link, which only shows if you're logged in as an
This code displays the content of the post entry. Now let's add in links for people to leave a comment.
comments_popup_link(__('Be the first to comment on this'), __('Read comment or leave one yourself '), __('Read the % comments or leave one
I specified the size for pop-up page comments. Then I defined the text of the comment link. You supply three values One for uncommented items, and two
for items with comments. (I dont' remember why at the time)
comments_template(); // Get wp-comments.php template
_e('Sorry, no posts matched your criteria.');
This is the end of the main loop. The part after "else" is text I write out if there were no matching post for the query made earlier.
In the next part (if(empty($this_page_comment) ) we make a decision to include a link for older or newer entries if needed.
That's all there is to it. I don't have a sidebar or header for this page, but if you download someone's template you'll see how it's easily
done. Usually the header, sidebar, and footer are in their own php file. This is how it's done on my actual blog page. I just call get_header(); and
get_sidebar(); before the posts. Then I call get_footer(); at the end.
[edit on 16-3-2007 by dbates]