Archived topic
Make tag pages show all posts assigned to the tag with no pagination
5 replies · Started by Michael on May 6, 2020
If this is beyond the level of support, please feel free to tell me to pound sand, and I'll hire a developer (as this is beyond my stackoverflow google ninja skills).
Is there a way to force Generatepress to ignore the wordpress archive settings for tags only and force it to show all the posts assigned to a tag on that tag page to avoid tag/page-2, 3 etc?
I make use of tags as actual navigable resource pages for the reader and SEO; they aren't just an after thought and I'd like to concentrate their authority, relevancy, etc onto one page.
The URL goes directly to one of my tag pages.
Hi there,
you can try using WordPress' pre_get_posts function with a PHP Snippet like so:
function tag_post_per_page( $query ) {
if( ! $query->is_main_query() )
return;
if ( is_tag() ){
//Display 50 posts for category-slug
$query->set( 'posts_per_page', 50);
}
}
add_action('pre_get_posts', 'tag_post_per_page', 1);
This sets it to display 50 - you can change that to -1 which will be unlimited - but that could overload your server if the tag has a lot of posts...
Dear David, please tell how to have listing alphabetically sort in this...
Hi there,
you can define more query->set parameters ie.
function tag_post_per_page( $query ) {
if( ! $query->is_main_query() )
return;
if ( is_tag() ){
//Display 50 posts for category-slug
$query->set( 'posts_per_page', 50);
//Set the order ASC or DESC
$query->set( 'order', 'ASC' );
//Set the orderby
$query->set( 'orderby', 'title' );
}
}
add_action('pre_get_posts', 'tag_post_per_page', 1);
Thanks David :-)
You're welcome