1
我有一個搜索結果頁面的問題,我在我的搜索頁面上看到的分頁是數字分頁,我想只有一個像這樣的網址是前一個和下一個分頁:WWW。 mywebsite.com/page/{pagenumber}/?s=word下面是我的代碼,我有麻煩修復它:WordPress的主題自定義分頁
在function.php我對這個
rendering the pagination links
-------------------------------------
function thrive_pagination() {
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1) {
$current_page = max(1, get_query_var('paged'));
if (! is_search()) {
echo paginate_links(array(
'base' => trim(get_pagenum_link(1), "/") . '/%_%',
'current' => $current_page,
'total' => $total_pages,
));
} else {
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => ((get_option('permalink_structure') && ! $wp_query->is_search) || (is_home() && get_option('show_on_front') !== 'page' && ! get_option('page_on_front'))) ? '?paged=%#%' : '&paged=%#%',
// %#% will be replaced with page number
'current' => $current_page,
'total' => $total_pages,
));
}
}
}
雖然我搜索頁面的分頁代碼是:
<?php $next_page_link = get_next_posts_link();
$prev_page_link = get_previous_posts_link(); ?>
<ul class="entry-nav">
<?php if ($next_page_link || $prev_page_link && ($next_page_link != "" || $prev_page_link != "")): ?>
<?php if (strpos($options['blog_layout'], 'masonry') === false): ?>
<li class="button next"><?php thrive_pagination(); ?></li>
</ul>
<?php endif; ?>
<?php endif; ?>