Archived topic
Hide archive pagination as a theme option
3 replies · Started by George on October 8, 2021
Viewing posts 1–4 of 4
I want to be able to hide pagination for the blog front page but I want it integrated with the theme, without using CSS. I thought I would use a hook element, is there a way to create archive pagination as a shortcode?
Hi there,
you can:
1. remove the archive navigation using this snippet:
add_action('wp',function(){
remove_action( 'generate_after_loop', 'generate_do_post_navigation' );
});
2. then create a shortcode to output your own pagination:
add_shortcode( 'db_pagination', function() {
ob_start();
echo '<div class="your-pagination-class">';
the_posts_pagination( array(
'end_size' => 2,
'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ),
'prev_text' => apply_filters( 'generate_previous_link_text', __( '← Previous', 'generatepress' ) ),
'next_text' => apply_filters( 'generate_next_link_text', __( 'Next →', 'generatepress' ) ),
) );
echo '</div>';
return ob_get_clean();
});
It works great, thanks, David!
Awesome - glad to hear that!
This archived topic is closed to new replies.