[Support request] blog pagination -> modify this?

Home Forums Support blog pagination -> modify this?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #491191
    Thomas

    Hi,
    in my old theme I had a pagination for my blog page, that showed me (assuming I am on page 20 of 321)
    Zurück 1 2 … 18 20 21 … 320 321 Weiter

    In GP Pro it shows
    ← Zurück 1 … 19 20 21 … 352 Weiter →

    Can I change it, that it shows 2 pages on start and two on the end of the list? I know that this can be done by modifying the index.php, but I am searching for a way that it still works after updating the theme to a newer version.

    GeneratePress 2.0.2
    GP Premium 1.5.6
    #491542
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try adding this function:

    add_filter( 'generate_pagination_mid_size', 'tu_increase_pagination_mid_size' );
    function tu_increase_pagination_mid_size() {
        return 2;
    }
    #491629
    Thomas

    Hi,
    this adds 2 in the middle part -> this works.
    But how add 1 to start and end of the list?

    Is it ok to add this code to the end of function.php or anywhere else?
    If I add it to function.php it will be overwritten on updates. 🙁

    #491824
    Tom
    Lead Developer
    Lead Developer

    Interesting – I can’t find anything that shows that’s possible. It may be worth asking over on https://wordpress.stackexchange.com in case I’m missing a filter somewhere.

    All custom PHP should be added using one of these methods: https://docs.generatepress.com/article/adding-php/

    #491935
    Thomas

    In the default wordpress themes it helps to add this to the index.php

    But I have no idea how to set this in GP.

    
    				the_posts_pagination( array(
    				 'type' => 'list',
    				 'end_size' => 2,	
    				 'mid_size' => 3	
    				));
    #492657
    Tom
    Lead Developer
    Lead Developer

    Nice site, I wonder why they don’t make all of the args available by a filter.

    We’ll have to do a workaround.

    Add this CSS:

    .nav-links {
        display: none;
    }
    
    .custom-pagination .nav-links {
        display: block;
    }

    Then add this PHP:

    add_action( 'generate_paging_navigation', 'tu_add_custom_pagination' );
    function tu_add_custom_pagination() {
    	echo '<div class="custom-pagination">';
    		the_posts_pagination( array(
    			'end_size' => 2,
    			'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ),
    			'prev_text' => apply_filters( 'generate_previous_link_text', __( '&larr; Previous', 'generatepress' ) ),
    			'next_text' => apply_filters( 'generate_next_link_text', __( 'Next &rarr;', 'generatepress' ) ),
    		) );
    	echo '</div>';
    }
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.