Title: WordPress Custom Post Loop duplicate content
Last modified: October 15, 2016

---

# WordPress Custom Post Loop duplicate content

 *  [turbonostics85](https://wordpress.org/support/users/turbonostics85/)
 * (@turbonostics85)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/wordpress-custom-post-loop-duplicate-content/)
 * This is my first time posting on here. I’ve found this site very helpful in the
   past. I greatly appreciate the dedication the developers have to support each
   other.
 * I’m building a testimonial slider in wordpress, for a bit of background knowledge(
   if required) I’ve followed; How to Add Rotating Testimonials in WordPress as 
   a starter. Then used Bootstrap to code the testimonial slider, Simple Bootstrap
   Testimonial Carousel (codepen.io/danielmdesigns/pen/yNzJwB)
 * I’m happy with the HTML/Jquery side. It’s the PHP loop that’s given me grief.
   The PHP was taken from the How to Ad Rotating Testimonials in WordPress from 
   WP Beginner and tried modifying it for my own use.
 * I’ve made a comment of the issue in the php code, With my limited PHP knowledge,
   I’m looking to only release one testimonial per slide, but from trial and error
   it is to do with the ‘php else’ statement. Currently in the slider it’s releasing
   all the testimonials stored in the CMS, where it should be releasing one per 
   slider. If you look at the array code, it has a counter on it.
 * It’s the same for endwhile and end if statement, I’m guessing something needs
   to be added to the php else statement, but unsure what type of if statement.
 *     ```
       <div class=”carousel slide” id=”quote-carousel” data-ride=”carousel”>
   
       <!– Bottom Carousel Indicators –>
   
       <li data-target=”#quote-carousel” data-slide-to=”0″ class=”active”>
       <li data-target=”#quote-carousel” data-slide-to=”1″>
       <li data-target=”#quote-carousel” data-slide-to=”2″>
       <!– Carousel Slides / Quotes –>
       <div class=”carousel-inner”>
   
       <?php
       $args = array( ‘post_type’ => ‘testimonial’, ‘posts_per_page’ => 10 );
       $loop = new WP_Query( $args );
       if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
       $data = get_post_meta( $loop->post->ID, ‘testimonial’, true );
       static $count = 0;
       if ($count == “1”) { ?>
   
       <!– Quote 1 –>
       <div class=”item active”>
       <div class=”row”>
       <div class=”col-sm-12″>
       <p><?php the_content(); ?></small>
   
       </div>
       </div>
       </div>
   
       <!– Quote 2 –>
       <div class=”item”>
       <div class=”row”>
       <div class=”col-sm-12″>
   
       <!– this php else is the issue, one testimonial should only release per slide –>
       <?php } else { ?>
       <p><?php the_content(); ?>
       </p>
       <small></small>
       </div>
       </div>
       </div>
       <?php
       $count++; }
       endwhile;
       endif; ?>
       </div>
       ```
   
 * _[moderator note: code marked properly – see [https://codex.wordpress.org/Forum\_Welcome#Posting\_Code](https://codex.wordpress.org/Forum_Welcome#Posting_Code)]_
    -  This topic was modified 9 years, 5 months ago by [turbonostics85](https://wordpress.org/support/users/turbonostics85/).

The topic ‘WordPress Custom Post Loop duplicate content’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * 0 replies
 * 1 participant
 * Last reply from: [turbonostics85](https://wordpress.org/support/users/turbonostics85/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/wordpress-custom-post-loop-duplicate-content/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
