我正在为WP中的下一个/上一个链接处理一个非常奇怪的代码,我似乎无法使其仅在同一类别中工作。
我在这里尝试了以前的答案,没有用。
<?php
the_post_navigation( array(
'next_text' => '<span class="meta-nav" aria-hidden="true"><span class="pagination__text">' . esc_html__( 'Next', 'nubia' ) . '</span><span class="pagination__icon" data-icon="ei-chevron-right" data-size="s"></span></span> ' .
'<span class="screen-reader-text">' . esc_html__( 'Next post:', 'nubia' ) . '</span>' .
'<span class="post-title">%title</span>',
'prev_text' => '<span class="meta-nav" aria-hidden="true"><span class="pagination__icon" data-icon="ei-chevron-left" data-size="s"></span><span class="pagination__text">' . esc_html__( 'Previous', 'nubia' ) . '</span></span>' .
'<span class="screen-reader-text">' . esc_html__( 'Previous post:', 'nubia' ) . '</span>' .
'<span class="post-title">%title</span>',
) );
?>
我只需要帮助才能实际更改适当的行以使其起作用。谢谢。
答案 0 :(得分:0)
那是答案:) 只需在两端添加: 'in_same_term'=>是,
<?php
the_post_navigation( array(
'next_text' => '<span class="meta-nav" aria-hidden="true"><span class="pagination__text">' . esc_html__( 'Next', 'nubia' ) . '</span><span class="pagination__icon" data-icon="ei-chevron-right" data-size="s"></span></span> ' .
'<span class="screen-reader-text">' . esc_html__( 'Next post:', 'nubia' ) . '</span>' .
'<span class="post-title">%title</span>', 'in_same_term' => true,
'prev_text' => '<span class="meta-nav" aria-hidden="true"><span class="pagination__icon" data-icon="ei-chevron-left" data-size="s"></span><span class="pagination__text">' . esc_html__( 'Previous', 'nubia' ) . '</span></span>' .
'<span class="screen-reader-text">' . esc_html__( 'Previous post:', 'nubia' ) . '</span>' .
'<span class="post-title">%title</span>', 'in_same_term' => true,
) );
?>