Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

There are over 200 posts tagged with the keyword "Apple."

Each tag page -- example.com/tag/apple/page/2/ -- shows 10 posts.

So there are 20 tag pages.

Is it possible to show all these 200 post (links) in one page? I don't want to show any of the excerpt -- just consolidate all those 200 links in one page.

Appreciate your help!

share|improve this question
    
do you want example.com/tag/apple/ to show all posts, or a separate page? –  Milo Feb 25 '13 at 19:02
    
When someone visits the tag page -- example.com/tag/apple -- he/she should be shown all the posts. No pages. Thanks, Milo! –  Sid Feb 25 '13 at 19:28

2 Answers 2

up vote 3 down vote accepted

This is what I would consider the correct solution, and is the solution alluded to by Milo's comment (if I am not mistaken).

function alter_ppp_for_tags_wpse_88337($qry) {
  if ( is_tag() && $qry->is_main_query() ) {
    $qry->set('posts_per_page','-1');
  }
}
add_action('pre_get_posts','alter_ppp_for_tags_wpse_88337');

Using query_posts will cause two requests to the database-- the main query, and the query triggered by the use of query_posts. By using a filter on pre_get_posts you alter the main query before posts are fetched and thus only hit the database once.

Reference:

http://codex.wordpress.org/Class_Reference/WP_Query

share|improve this answer
2  
And if you want to target the "apple" tag specifically: if (is_tag( 'apple' ) ). Also, be sure to include && $query->is_main_query() in the conditional. –  Chip Bennett Feb 25 '13 at 19:47
    
S_ha_dum, you rock! That code works perfectly. Thanks a lot. Also, Chip Bennett, appreciate your response. Boy, you guys are genius. :) –  Sid Feb 26 '13 at 5:24

Its possible. You need to modify parameters in query_posts(). Use:

query_posts('tag'=>'apple', 'posts_per_page'=>-1)

'nopaging'=>1 can also be used for listing all items. Check Parameters for detail.

share|improve this answer
3  
Do not use query_posts, ever. Modify the main query via pre_get_posts, create additional queries via WP_Query. –  Milo Feb 25 '13 at 19:10
    
Now I am more confused -- should I follow Nilambar's advice or go through Milo's links. Also, not sure where to add these codes! Appreciate your help. –  Sid Feb 25 '13 at 19:30
    
You should go through Milo's links. query_posts is pretty much always a bad idea. Just don't use it. –  s_ha_dum Feb 25 '13 at 19:37
    
Do not use query_posts(), ever, for anything. There is always a better, more appropriate way to modify or create a query. –  Chip Bennett Feb 25 '13 at 19:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.