Happy
Happy

Reputation: 891

Different number of posts (WordPress)

We have selected to show 5 posts per page in admin panel.

And we want to show 10 posts per page in specific category (for example, "projects" width id=2).

How would we do it?

Upvotes: 1

Views: 186

Answers (3)

Jul
Jul

Reputation: 11

I had the same problem.

This worked for me:

if ( is_category(2) ){
global $query_string;
query_posts( $query_string . "&posts_per_page=500" );

Upvotes: 1

Pali Madra
Pali Madra

Reputation: 69

This should be used in the main loop only. . If you want to create separate Loops outside of the main one, you should create separate WP_Query objects and use those instead.

Cheers Pali Madra

Upvotes: 1

Fred Bergman
Fred Bergman

Reputation: 2020

Change the normal loop to a query post. Like

if ( is_category(2) ){

//The Query
query_posts('posts_per_page=5');

//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
   the_content();
endwhile; else:
   echo'Nothing here...';
endif;

//Reset Query
wp_reset_query();

}

Upvotes: 1

Related Questions