我正在尝试在Wordpress主页的底部创建分页链接。单个帖子是例外,他们需要在页面底部有“上一个”和“下一个”按钮。但是我的代码出现了语法错误:
<nav class="navigation clearfix">
<ul class="pager">
<?php if ( is_singular() ) { ?>
<li class="previous"><?php next_post_link( '%link', '← %title' ); ?></li>
<li class="next"><?php previous_post_link( '%link', '%title →' ); ?></li>
<?php } else {
global $wp_query;
$big = 999999999; // need an unlikely integer
echo 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
) );
?>
</ul>
</nav>
我找不到任何错误。有任何想法吗? 感谢
答案 0 :(得分:0)
嗨,请尝试使用此代码,因为}
befor </ul>
<nav class="navigation clearfix">
<ul class="pager">
<?php if ( is_singular() ) { ?>
<li class="previous"><?php next_post_link( '%link', '← %title' ); ?></li>
<li class="next"><?php previous_post_link( '%link', '%title →' ); ?></li>
<?php } else {
global $wp_query;
$big = 999999999; // need an unlikely integer
echo 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
) );
}
?>
</ul>
</nav>