I’ve been trying to create a “blog” page within a portfolio site of mine that only displays posts that I’ve categorized as “Blog”. My goal is to only display 5 posts per page and have pagination at work. So basically just a simple blog within my site. I could just do a loop, but my portfolio entries are also posts (categorized as well: “Illustration” “Graphic” etc) and I just want “Blog” on this page. I tried a query but the pagination wouldn’t show up.
My answer may be as simple as referencing this codex post: http://codex.wordpress.org/Pages#A_Page_of_Posts
I think what they are trying to communicate is their example category name is “Category” and I need to c/p the whole code and switch out “Category” for my category, “Blog”. However, I am sure the word category is an essential part of the code in specific places so I am not sure where the word is just part of the code and where I’m supposed to change it out. Things would be far more clear if they had chosen a different word as an example instead of one that already exists within the code, but whatever. Or maybe I’m just misunderstanding the whole thing?
Cutting to the chase:
-
What “Category”s in that article should I replace with “Blog”?
-
Conversely, is what I’m looking to accomplish not to be found in that article?
If you made it through my long-winded question without wincing too hard, I really appreciate it!!
1 Answer
Are you writing a custom query? If so, are you using the paged function in your query?
It would look something like this:
<?php
query_posts( array(
'posts_per_page' => 5,
'cat' => '10',
'paged' => ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1 ),
) );
while( $new_query->have_posts() ) : $new_query->the_post();
?>
// loop stuff here
<?php endwhile; ?>
<?php next_posts_link( '« Older Entries', $new_query->max_num_pages ) ?>
<?php previous_posts_link( 'Newer Entries »' ) ?>