I have my template taxonomy-$taxonomy.php
(here, 'catmaison').
In this taxonomy, I have 3 terms ('au-fil-du-temps', 'elaboration-distillation', 'plantes-epices').
Each terms of this taxonomy are displayed in my main menu.
I would like to display the first post of each term when i click in the menu.
Example : When I click on 'Au Fil Du Temps' in the menu, i would like to display the first post.
You can see my current code bellow :
<?php get_header(); ?>
<!-- CONTENT PAGE -->
<section class="sous-pages ptb-60" id="product-page" style="background: url('<?php echo $image['url']; ?>'); height: 700px;">
<div class="container">
<h1>taxonomy catmaison</h1>
<div class="row">
<?php
$args = array(
'post_type' => 'maison',
'posts_per_page' => 1,
'orderby' => 'ASC',
'ignore_sticky_posts' => 1,
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'catmaison',
'field' => 'slug',
'terms' => 'au-fil-du-temps',
),
array(
'taxonomy' => 'catmaison',
'field' => 'slug',
'terms' => 'elaboration-distillation',
),
array(
'taxonomy' => 'catmaison',
'field' => 'slug',
'terms' => 'plantes-epices',
),
),
);
// Custom query.
$query = new WP_Query( $args );
// Check that we have query results.
if ( $query->have_posts() ) {
// Start looping over the query results.
while ( $query->have_posts() ) {
$query->the_post();
?>
<!-- PAGE CONTENT -->
<div class="col-xl-4 offset-xl-6 product-type-2">
<h1>single produit</h1>
<h2><?php the_title(); ?></h2>
<hr>
<p class="intro-texte pb-20"><?php the_field('page_introduction'); ?></p>
<p><?php the_field('project_description'); ?></p>
</div>
<div class="col-xl-12">
<div class="float-left"><?php previous_post_link('%link','<img src="' . get_bloginfo("template_directory") . '/img/general/arrow_left_shadow.png" />'); ?></div>
<div class="float-right"><?php next_post_link('%link','<img src="' . get_bloginfo("template_directory") . '/img/general/arrow_right_shadow.png" />'); ?></div>
</div>
<!-- PAGE CONTENT -->
<?php
} // End while
} // End if
else { echo '<p>Aucune actualité trouvée</p>'; } ?>
<?php wp_reset_postdata(); ?>
</div><!-- End Row -->
</div>
</section>