哪里是单词press搜索分页

文字压搜索分页在哪里?

我用了这个'n我的搜索页面:

<?php echo paginate_links(); ?>

它返回分页,但我想添加引导分页,但我找不到它,这在哪里?如何添加课程?


阿晨1998
浏览 151回答 2
2回答

偶然的你

将以下内容添加到文件底部:search.php<?phpif ( $GLOBALS['wp_query']->max_num_pages <= 1 ) {&nbsp; return;}$args = wp_parse_args(&nbsp; $args,&nbsp; array(&nbsp; &nbsp; 'mid_size' => 2,&nbsp; &nbsp; 'prev_next' => true,&nbsp; &nbsp; 'prev_text' => __( '&laquo;' ),&nbsp; &nbsp; 'next_text' => __( '&raquo;' ),&nbsp; &nbsp; 'screen_reader_text' => __( 'Posts navigation' ),&nbsp; &nbsp; 'type' => 'array',&nbsp; &nbsp; 'current' => max( 1, get_query_var( 'paged' ) ),&nbsp; ));$links = paginate_links( $args ); ?><nav>&nbsp; <ul class="pagination"><?phpforeach ( $links as $key => $link ) {?>&nbsp; &nbsp; <li class="page-item <?php echo strpos( $link, 'current' ) ? 'active' : ''; ?>"><?php echo str_replace( 'page-numbers', 'page-link', $link ); ?>&nbsp; &nbsp; </li><?php } ?>&nbsp; </ul></nav>

MMMHUHU

我也在寻找相同的解决方案来将其与引导分页链接一起使用,下面的代码在我的主题中100%工作。function bittersweet_pagination() {global $wp_query;if ( $wp_query->max_num_pages <= 1 ) return;&nbsp;$big = 999999999; // need an unlikely integer$pages = paginate_links( array(&nbsp; &nbsp; &nbsp; &nbsp; 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),&nbsp; &nbsp; &nbsp; &nbsp; 'format' => '?paged=%#%',&nbsp; &nbsp; &nbsp; &nbsp; 'current' => max( 1, get_query_var('paged') ),&nbsp; &nbsp; &nbsp; &nbsp; 'total' => $wp_query->max_num_pages,&nbsp; &nbsp; &nbsp; &nbsp; 'type'&nbsp; => 'array',&nbsp; &nbsp; ) );&nbsp; &nbsp; if( is_array( $pages ) ) {&nbsp; &nbsp; &nbsp; &nbsp; $paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');&nbsp; &nbsp; &nbsp; &nbsp; echo '<div class="pagination-wrap"><ul class="pagination">';&nbsp; &nbsp; &nbsp; &nbsp; foreach ( $pages as $page ) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "<li>$page</li>";&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp;echo '</ul></div>';&nbsp; &nbsp; &nbsp; &nbsp; }}使用函数调用索引.php例如;或任何其他文件。我还覆盖了一些引导样式,它可能会帮助你。.pagination-wrap {&nbsp; &nbsp; clear: both;&nbsp; &nbsp; display: block;&nbsp; &nbsp; overflow: hidden;&nbsp; &nbsp; text-align: center;}.pagination-wrap .pagination {&nbsp; &nbsp; margin-bottom: 0;&nbsp; &nbsp; margin-top: 0;}.pagination-wrap .pagination > li:first-child > a,&nbsp;.pagination-wrap .pagination > li:first-child > span {&nbsp; &nbsp; border-bottom-left-radius: 0px;&nbsp; &nbsp; border-top-left-radius: 0px;}.pagination-wrap .pagination > li:last-child > a,&nbsp;.pagination-wrap .pagination > li:last-child > span {&nbsp; &nbsp; border-bottom-right-radius: 0px;&nbsp; &nbsp; border-top-right-radius: 0px;}.pagination-wrap .pagination > li > a,.pagination-wrap .pagination > li > span {&nbsp; &nbsp; background-color: #4FBEBA;&nbsp; &nbsp; border: 1px solid #1BA5A0;&nbsp; &nbsp; padding: 10px 15px;&nbsp; &nbsp; font-weight: bold;&nbsp; &nbsp; color: #FFFFFF;}.pagination-wrap .pagination > li > a:hover,&nbsp;.pagination-wrap .pagination > li > span:hover,&nbsp;.pagination-wrap .pagination > li > a:focus,&nbsp;.pagination-wrap .pagination > li > span:focus {&nbsp; &nbsp; background-color: #1BA5A0;&nbsp; &nbsp; border-color: #189690;}.pagination-wrap .pagination .current {&nbsp; &nbsp; background-color: #1BA5A0;&nbsp; &nbsp; border-color: #189690;}.pagination-wrap .pagination .current:hover,.pagination-wrap .pagination .current span:hover {&nbsp; &nbsp; background-color: #189690;&nbsp; &nbsp; border-color: #148781;}祝你好运,兄弟。
打开App,查看更多内容
随时随地看视频慕课网APP