I'm using flexslider with wp and my slider have 2 slides in view as one, the problem is when i have Steady number of slides i got one extra blank slide,also at that case my newest two slides goes to last position, and when i have odd then everything is fine.

$post_counter = wp_count_posts('news');
$numOfPosts = (int)$post_counter->publish;
$i = 1;?>  <div class="flexslider flexslider-wrapper " id="slide1">
<div class="row nav-contain">
        <div class="flex-nav-container">
            <div class="flex-nav">

        </div><!-- /.flex-nav-container -->

    <ul class="slides">
        'showposts' => -1,
        'post_type' =>'news',
        'orderby' => 'publish_date',
        'order'   => 'DESC'

        if (have_posts()) : while (have_posts()) : the_post();

            <div class="col-md-6">
                <div class="description">
                    <div class="item-title">
                    <a class="item-date"><?php echo get_the_date(); ?></a>
            <h1><a href="<?php the_permalink();?>"><?php echo mb_strimwidth( get_the_title(), 0, 40, '...' );?></a></h1>
                    <div class="exceprt">
                    <?php echo  the_excerpt(); ?>

        if($i % 2 == 1 && $numOfPosts > 2){
            echo '</li><li>';

<div class="clearfix"></div>

EDIT: Partial solution to this is animationLoop: false, in this way i get all well sorted, but problem is that i need to use animationloop, last slide still empty also i provide my js:

    animation: "slide",
    controlsContainer: '#slide-1 .flex-nav',
    manualControls: '#slide-1 .flex-control-nav li',
    controlNav: false,
    slideshow: false,


REEDIT: When i remove animation:"slide", posts are in right orded (newest-oldest), but last slide stil empty.

  • query_posts should never be used and causes all manner of problems. Use WP_Query instead
    – Tom J Nowell
    Commented May 4, 2018 at 1:28
  • Thx for this @TomJNowell , will fix and avoid in future. Commented May 7, 2018 at 23:07

1 Answer 1


I solved issue with putting integer to -1,don't know really why this helped but if someone get same problem then maybe this will help to him.

<?php $i = -1;
 if (have_posts() ) : while ( have_posts() ) : the_post();
 if ($i%2 == 1) echo '</li><li>'; 
  • it's because your loop adds an opening <li> tag at the end, and the math is off, so you'd end up with 1 extra li tag, depending on wether an even or an odd number of posts were fetched
    – Tom J Nowell
    Commented May 4, 2018 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.