[Support request] Setting up standard pagination when using Generate Press with Generate Blocks

Home Forums Support [Support request] Setting up standard pagination when using Generate Press with Generate Blocks

Home Forums Support Setting up standard pagination when using Generate Press with Generate Blocks

Viewing 11 posts - 16 through 26 (of 26 total)
  • Author
    Posts
  • #2377767
    David
    Staff
    Customer Support

    The Block Element – Loop Template and the GB Query Look – Inherit Query from Template, is designed to allow you to build your own custom archive pages, whether that be for the Blog, your Post Categories or other custom post types.

    As it is an Archive page, the WP Query is already predefined.

    What it cannot do is add pagination to a custom query loop block, as that would require a static page that does not support post pagination.

    #2377807
    Chris

    I was hoping to use this to replace WP Show Posts with Generate Blocks. WP Show Posts will (would) add pagination links to the bottom of the posts with some limited options, with the correct url structure. I may just have to go back to using that, though I know it’s been officially replaced by Generate Blocks… unless I am misunderstanding you,

    Chris

    #2378477
    David
    Staff
    Customer Support

    Can you share an example page where i can see what you have built with WP Show Posts ? And a little explanation as to what is specific for that query ?

    #2379272
    Chris

    For example:

    https://consumer.press/shopping/

    that is actually a static page using WP Show Posts with the parameters ‘posts’ and taxonomy-category ‘shopping’, with working pagination (urls formatted as /page/2/, /page/3/ etc…).

    I’d like to use Generate Press/Blocks with custom parameters, but need to replicate the pagination the way that WP Show Posts did them, so those same paginated urls can be used.

    It seems like if WP Show Posts could have both parameters and pagination (page/2/ type url formatting) on a non-archive page, GeneratePress/Blocks would be able to replicate that feature, no? That’s what I thought the pagination feature added to 2.2 would allow for,

    Chris

    PS, an example of the settings in WP Show Posts with selected taxonomy and pagination:

    #2379742
    David
    Staff
    Customer Support

    I assume you’re using a redirect or the method provided here to replace the default category archives with static pages ?

    #2379912
    Chris

    Through a redirect

    #2379931
    David
    Staff
    Customer Support

    OK, so to use the Loop Template, you would remove the redirect so it displays the actual category archive. Then the pagination will work.

    #2380169
    Chris

    So… are you saying I can use Generate Blocks on archive pages (home/categories) with custom parameters? Or am I misunderstanding you?

    If that is correct, can you point me to the documentation for putting Generate Blocks on archive pages? I haven’t seen that,

    Chris

    #2380187
    David
    Staff
    Customer Support

    What are the custom parameters? – the example you provided was just a Posts in a specific category ? No ?

    #2380476
    Chris

    Correct, that was the example with WP Show Posts, but I was hoping to use Generate Blocks to exclude a tag (“expired”) and have the pagination work as I needed,

    Chris

    #2380933
    David
    Staff
    Customer Support

    You can use a PHP Snippet to exclude posts with a specific tag eg.

    
    function excludeTagId($query) {
      $tag_Ids = array( <code>33</code> );
    
      if ($query->is_main_query() && ! is_admin() && $query->is_category() ) {
        $query->set( 'tag__not_in', $tag_Ids );
      }
    }
    add_action('pre_get_posts', 'excludeTagId');

    Change the 33 to the ID of the Tag term you want to exclude.
    And this will remove those posts from the Main Query and your Category archives.

    Then you can built all your Archive pages using either a single: Loop Template or Content Template.

Viewing 11 posts - 16 through 26 (of 26 total)
  • You must be logged in to reply to this topic.