Tony
Tony

Reputation: 19151

How do I get ALL posts in a category with Wordpress?

This works pretty good except it is limited to 10 posts since my blog is set to show 10 posts maximum.

   $featured_query = new WP_Query('cat=3');

        while( $featured_query->have_posts() ){
            $featured_query->the_post();
            $postcount++;
            ...

How can I override that setting and get ALL posts in that category regardless of the maximum posts setting?

Upvotes: 4

Views: 6483

Answers (3)

mrphpguru
mrphpguru

Reputation: 31

This is best way to do the list of a particular category..

>  $catPost = get_posts(get_cat_ID("NameOfTheCategory"));

> foreach ($catPost as $post) : setup_postdata($post); ?>
>        <div>
>              <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
>              <p><?php the_content(); ?></p>
>        </div> <?php  endforeach;?>

Thanks MrPhpGuru

Upvotes: 1

Tyler Carter
Tyler Carter

Reputation: 61557

Use showposts=-1. This will override the defaults posts setting. Per this: http://codex.wordpress.org/Template_Tags/query_posts#Post_.26_Page_Parameters

Upvotes: 1

Jared
Jared

Reputation: 7233

Does query_posts('cat=3') do what you want?

Upvotes: 0

Related Questions