我正在尝试在我的 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>
我找不到任何错误。有什么想法吗? 谢谢
嗨,请尝试一下您缺少的代码
}
之前</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>