Site logo

Archived topic

blog pagination -> modify this?

5 replies · Started by Thomas on February 8, 2018

Viewing posts 1–6 of 6

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.

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;
}

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. :-(

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	
				));

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>';
}
This archived topic is closed to new replies.