嗨,我想在自定义模板中添加分页。模板基于参数(过滤器/下拉列表)工作。
这是分页代码:
echo paginate_links( array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '&page=%#%',
'current' => max( 1,$paged ),
'total' => $query_search->max_num_pages,
'prev_text' => '«',
'next_text' => '»',
'add_args' => array(
'deal' => get_query_var('deal'),
//'card' => get_query_var('card'),
)
) );
它会显示带有链接的分页:
https://www.dealfinder.lk/search/?deal=happy-hour&paged=2
https://www.dealfinder.lk/search/?deal=happy-hour&paged=3
https://www.dealfinder.lk/search/?deal=happy-hour&paged=4
但是我单击关于链接的链接,该链接转换为以下网址:
https://www.dealfinder.lk/search/2/?deal=happy-hour
https://www.dealfinder.lk/search/3/?deal=happy-hour
https://www.dealfinder.lk/search/4/?deal=happy-hour
当我在第二,第三或第四页中打印get_query_var('paged')或get_query_var('page')时,它将返回0。
谢谢。