Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Need two pages with all posts displayed WordPress


I need to have two different pages on my site that display posts differently. I need all posts to display from all categories.

The front page acts as the normal blog page that displays recent posts. I need to have a separate Archives page that also displays all posts but styled differently.

I have both pages created but how do I get the archive page to display all the posts? I found this but it requires having to use a custom field.

is there a way to write a custom loop that uses query_posts() and grab all categories in an array or something?

Answers (1)


Jens Filipsson answers:

Something like this should work:

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'posts_per_page' => -1,
'paged' => $paged

Dan | gteh comments:

thanks that did it.

can you explain what it all does so I know for the future.

Dan | gteh comments:

I know the post_per_page part, but what is 'paged' doing?

Jens Filipsson comments:

Actually it's for making paging work, so if you want to display all posts on one page, you might not need it here when I think about it. You could try without it as well.

For instance you can make use of it like this:

<?php if ( $paged < 2 ) { ?>
<p>Text for first page of Category archive.</p>
<?php } else { ?>
<p>Text for subsequent pages of Category.
Can be left out.</p>
<?php } ?>