Wordpress 分页不让我转到第 2 页(我猜是 .htaccess 重定向)
Wordpress pagination don't let me go to page 2 (.htaccess redirection I guess)
我的 post 中有分页。我以前做过类似的事情,效果很好。现在我正在将代码重写到另一个页面,但我被卡住了。
例如我有分页的页面:
http://localhost/est/witaj-swiecie/
我用 link 单击第 2 页:
http://localhost/est/witaj-swiecie/page/2/
然后 return 让我回到:
http://localhost/est/witaj-swiecie/
之前我在另一个页面上很容易做到,但是代码有点乱。
我的代码(略有删减):
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$this->query = array (
'post_type' => 'oferta',
'post_status' => 'published',
'paged' => $paged,
'pagination' => true,
'posts_per_page' => '1',
'order' => 'ASC',
'orderby' => 'date',
);
$big = 999999999;
$post[0]['pagination'] = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $query->max_num_pages,
'prev_text' => '« Poprzednia',
'next_text' => 'Następna »',
) );
一切都是使用带有自定义查询的示例完成的:
https://codex.wordpress.org/Function_Reference/paginate_links
好的,我找到问题了。我试图在 post 上使用带有简码的那些,而不是在页面上。在页面上使用它解决了我的问题。
我的 post 中有分页。我以前做过类似的事情,效果很好。现在我正在将代码重写到另一个页面,但我被卡住了。
例如我有分页的页面: http://localhost/est/witaj-swiecie/ 我用 link 单击第 2 页: http://localhost/est/witaj-swiecie/page/2/ 然后 return 让我回到: http://localhost/est/witaj-swiecie/
之前我在另一个页面上很容易做到,但是代码有点乱。
我的代码(略有删减):
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$this->query = array (
'post_type' => 'oferta',
'post_status' => 'published',
'paged' => $paged,
'pagination' => true,
'posts_per_page' => '1',
'order' => 'ASC',
'orderby' => 'date',
);
$big = 999999999;
$post[0]['pagination'] = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $query->max_num_pages,
'prev_text' => '« Poprzednia',
'next_text' => 'Następna »',
) );
一切都是使用带有自定义查询的示例完成的: https://codex.wordpress.org/Function_Reference/paginate_links
好的,我找到问题了。我试图在 post 上使用带有简码的那些,而不是在页面上。在页面上使用它解决了我的问题。