0

I have a page that displays posts by category: https://www.worldwideholidaysclub.com/holidays/

But, I want to have different pages for the main tags in order to promote the pages separately. My problem: 1. I am able to get the tags correctly, BUT am unable to integrate the pagination counter correctly. 2. The page is set to display 6 posts per page; and I currently have 5 posts in all for this tag_id. 3. With 5 posts, the first page displays correctly and then gets duplicated as a second page.

I've searched most forums but still can't come up with a solution. My code is below (stripped of most of the html). Any help would be most highly appreciated. With much thanks in advance...

<?php if ( have_posts() ) : ?>
    <!--- <header class="page-header"> -->
        <?php
            $args = array(
            'post_type' => 'post',
            'tag_id' => '259',
            'posts_per_page' => -1,
            'post__not_in' => get_option( 'sticky_posts' )
            );
            $query = new WP_Query( $args );
        ?>
    <!-- </header>   .page-header -->
<?php endif; ?>

<!--Main layout-->

    <?php
    if ( $query->have_posts() ) {
    $counter = 1;
    while ( $query->have_posts() ) {
    $query->the_post();
    ?>

    <!------ Start Output tags ---------->

                <?php the_post_thumbnail( 'medium-large', array( 'class'=> 'img-fluid')); ?>
                <a href="<?php echo get_permalink() ?>">

                </a>

            <!--Excerpt-->
            <a href="" class="pink-text">

                   <!-- <?php the_category(', '); ?> --> <?php the_tags(' '); ?>

            </a>
            <?php the_title(); ?>

            <?php the_excerpt(); ?>
            <a href="<?php echo get_permalink() ?>" class="btn btn-light-blue btn-md">Read more</a>

    <!------ end Output tags ---------->

      <?php
      if (( $counter) % 3 == 0) {
      ?>
      </div>
      <!--Grid row-->
      <!--Grid dynamic row-->
      <div class="row">
      <?php
      }
      $counter++;
      } // end while
      } // end if
      ?>
      </div>
      <!-- Card deck -->

        <?php mdb_pagination()  ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.