[Support request] Make tag pages show all posts assigned to the tag with no pagination

Home Forums Support [Support request] Make tag pages show all posts assigned to the tag with no pagination

Home Forums Support Make tag pages show all posts assigned to the tag with no pagination

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1273059
    Michael

    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.

    #1273598
    David
    Staff
    Customer Support

    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…

    #1276182
    Anil

    Dear David, please tell how to have listing alphabetically sort in this…

    #1276553
    David
    Staff
    Customer Support

    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);
    #1277418
    Anil

    Thanks David 🙂

    #1277646
    David
    Staff
    Customer Support

    You’re welcome

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.