The question:
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!
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
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
Method 2
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0