Bootstrap的pagination函数


Updated on: September 1, 2020 in Wordpress by

//also need to change thr core file of the a tag and the span tag with the file name of generate template.php
function get_bootstrap_paginate_links() {
	ob_start();
	?>
		<div class="pages clearfix">
			<?php
				global $wp_query;
				$current = max( 1, absint( get_query_var( 'paged' ) ) );
				$pagination = paginate_links( array(
					'base' => str_replace( PHP_INT_MAX, '%#%', esc_url( get_pagenum_link( PHP_INT_MAX ) ) ),
					'format' => '?paged=%#%',
					'current' => $current,
					'total' => $wp_query->max_num_pages,
					'type' => 'array',
					'prev_text' => '&laquo;',
					'next_text' => '&raquo;',
				) ); ?>

			<?php if ( ! empty( $pagination ) ) : ?>
				<ul class="pagination justify-content-center">
					<?php foreach ( $pagination as $key => $page_link ) : ?>
						<li class="page-item paginated_link<?php if ( strpos( $page_link, 'current' ) !== false ) { echo ' active'; } ?>">
							<?php echo $page_link;

 ?>
								
						</li>
					<?php endforeach ?>
				</ul>
			<?php endif ?>
		</div>


	<?php
	
}
function wa_paginate_links() {
	echo get_bootstrap_paginate_links();
}