[wp-hackers] Custom Page Template - can't see the forest through the trees

Mike Walsh mike_walsh at mindspring.com
Fri Apr 2 14:21:11 UTC 2010


I am stuck doing something I think should be rather simple but I can't seem
to see why it isn't working but suspect it is my lack of knowledge of the
loop.

 

I want to create a page template that is essentially the same as the main
index.php except that it will only shows posts from a single category.  I
can't get it to work correctly, the only thing I can do is get it to display
the single most recent post from the category.

 

I referred to this page on the Codex:

 

http://codex.wordpress.org/Template_Tags/query_posts#Category_Parameters

 

I thought I could simply do this outside my loop:

 

                                <?php
query_posts('cat=23&posts_per_page=5');?>

 

I currently have three posts with the category ID of 23 and all three appear
when clicking on the category link.  If I examine  $posts after running the
above query_posts() it only has one post, the most recent one.

 

Is there something special about using the loop on a page template that I
don't understand?

 

Thanks,

 

Mike 

 

--

Mike Walsh - mike underscore walsh at mindspring dot com

 



More information about the wp-hackers mailing list