WP : Custom Post Type pagination by cats Issue

51 views Asked by At

I'm going crazy I'm working on a wordpress mobile theme and i have an issue with the pagination of my custom post type. Explanations :

This is a winery website. On this website there is 3 cats of wine. on single-wine.php I want to be able to navigate between all wine wich are on the same cat. It doesn't work like i want and i don"t know why cause each use the same code :

Cat 1 : Dry wines - Pagination looks good

Cat 2 : Vintage wines - I can navigate only between 3 wines ( >< why ..?)

Cat 2 : oxy wines - I can navigate only between 1 wines ( >< why ..?) Next_post and previous_post function have the same link all the time.

Can you help me ? Actually i really don't understand where is the issue, i'm on it since 2 days. the single-wine query ? The pagination ?

Try it on mobile to understand : mas.triangle-fr.com

Single-wine.php

<?php include('winecats-2.php');?>
<?php wp_reset_query(); ?>
<?php if (have_posts()) : ?> <?php while ( have_posts() ) : the_post();  ?>  
<section id="wine-head">
<div class="containerWine">
<?php previous_post_link( '%link', '<i class="left"></i>', TRUE); ?>
<?php next_post_link( '%link','<i class="right"></i>', TRUE); ?>

Wine-cats-2.php

<?php $args = array(
'post_type' => 'vins',
'cat' => the_category_ID($echo=false),
);
$query = new WP_Query( $args ); ?>
<?php if ($query->have_posts()) : ?>
<header class="cat-header">
<h3 class="wine_nav"><i class="fa fa-caret-down"></i> <?= the_category($post->ID); ?> </h3>
<ul id="wine-dropdown">      
    <?php while ($query->have_posts()) : $query->the_post(); ?>
    <li class="wine-item"><a href="<?php the_permalink(); ?>"  class="" data-id="" id="<?= $post->post_name?>"><?php the_title() ?></a></li> 
    <?php endwhile; ?>
</ul>

0

There are 0 answers