php WordPress的Bootstrap分页

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WordPress的Bootstrap分页相关的知识,希望对你有一定的参考价值。

// https://www.kevinleary.net/wordpress-pagination-paginate_links/


/*
 * custom pagination with bootstrap .pagination class
 * source: http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/
 */
function bootstrap_pagination( $echo = true ) {
	global $wp_query;

	$big = 999999999; // need an unlikely integer

	$pages = paginate_links( array(
			'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
			'format' => '?paged=%#%',
			'current' => max( 1, get_query_var('paged') ),
			'total' => $wp_query->max_num_pages,
			'type'  => 'array',
			'prev_next'   => true,
			'prev_text'    => __('« Prev'),
			'next_text'    => __('Next »'),
		)
	);

	if( is_array( $pages ) ) {
		$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');

		$pagination = '<ul class="pagination">';

		foreach ( $pages as $page ) {
			$pagination .= "<li>$page</li>";
		}

		$pagination .= '</ul>';

		if ( $echo ) {
			echo $pagination;
		} else {
			return $pagination;
		}
	}
}

以上是关于php WordPress的Bootstrap分页的主要内容,如果未能解决你的问题,请参考以下文章

php Wordpress Bootstrap 4.1分页(使用自定义WP_Query()和全局$ wp_query支持)

php Wordpress Bootstrap 4.1分页(使用自定义WP_Query()和全局$ wp_query支持)

php PHP Wordpress分页

Wordpress 插件 HTML Bootstrap + PHP

php 使用Wordpress循环的Bootstrap列

使用functions.php将Bootstrap排队到Wordpress