我正在寻找一种方法来显示页面导航的两个按钮“上一个”和“下一个”,但使用下面的代码,我只能显示一个。我不理解代码中的错误(如下所示):
<div class="cover--nav">
<?php
$currenttPostId = get_the_ID();
$theCategory = get_the_terms(get_the_ID(),\'recipe_category\');
global $wp_query;
$args = array(
\'post_type\' => \'recipe\',
\'orderby\' => \'rand\',
\'post_status\' => \'publish\',
\'recipe_category\'=> !empty($theCategory)? $theCategory[0]->slug : \'\',
\'post__not_in\' => array($currenttPostId),
\'posts_per_page\' => 2,
\'paged\' => $paged //very important
);
$wp_query = new WP_Query($args);
$prevNext = array();
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
the_title();
endwhile;
endif;
wp_reset_postdata();
$prev_label = "<span class=\'cover--nav-label\'>" . _e(\'Recette précédente\', \'marque\') . "</span>";
$prev_arrow = "<svg class=\'icon icon-arrow-prev\' role=\'presentation\' focusable=\'false\'><use xlink:href=\'" . get_template_directory_uri() . "/images/symbol-defs.svg#icon-arrow-prev\'></use></svg>";
$prev_text = $prev_label . $prev_arrow;
$next_label = "<span class=\'cover--nav-label\'>" . _e(\'Recette suivante\', \'marque\') . "</span>";
$next_arrow = "<svg class=\'icon icon-arrow-next\' role=\'presentation\' focusable=\'false\'><use xlink:href=\'" . get_template_directory_uri() . "/images/symbol-defs.svg#icon-arrow-next\'></use></svg>";
$next_text = $next_label . $next_arrow;
the_posts_navigation( array(
\'prev_text\' => $prev_text,
\'next_text\' => $next_text,
) );
?>
</div>
事情就是这样:
我想得到以下示例: