Devam Ediyor

Prevent empty div after post loop

Hi

The following code inserts a div with row class every 2 posts. It works fine except if there are an even number of posts/multiples of 2, it adds an extra empty div to the end of the loop. Can anyone help fix this for me?

<div class="row">

<?php

$connected = new WP_Query( array(

'connected_type' => '2-col-module_to_pages',

'connected_items' => get_queried_object(),

'nopaging' => true,

) );

if ($connected->have_posts() ) : while ($connected->have_posts()) : $connected->the_post(); ?>

<div class="tile">

<div class="wrapper">

<div class="content">

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

</div>

</div>

</div>

<?php $counter++;

if ($counter % 2 == 0 ) {

echo '</div><div class="row">';

}

endwhile; wp_reset_postdata(); endif; ?>

</div>

Beceriler: PHP, WordPress

Daha fazlasını görün: prevent, div, php post array, div fix, post content wordpress php, empty, wordpress wrapper, tile code, loop row php, counter post, loop post number php, wordpress counter, array div, wordpress loop, div array php, div array, collapse div loop, internetexplorer object post method, php loop row, php loop, loop php, div php, div post message script, post adds, code div

İşveren Hakkında:
( 13 değerlendirme ) London, United Kingdom

Proje NO: #6502180

Seçilen:

mayanksm7

I m expert in this. I have +5years experience. Following are my recently completed project: Wordpress http://billyskinnerlaw.com/ http://www.hairtrans.com/ http://www.eifitness.com/ http://www.etradevideo.com/ Daha fazlası

1 gün içinde 17£ GBP
(135 Değerlendirme)
6.3
gopaldbr

We believe good design is like good manners, you just simply have it and you do not need to prove it. You might not find us on Award lists and we do not aim to get any award. Our award = superb result = happy client. W Daha fazlası

1 gün içinde 10£ GBP
(5 Değerlendirme)
1.9

4 freelancer bu iş için ortalamada 15£ teklif veriyor

mdsharifulhaque

Dear Sir, I have read your job description. I can do this job. I have 5 years experience about wordpress. You can check my portfolio for my previous work. I am available form now and weekly 40 hours. Waiting for your r Daha fazlası

1 gün içinde 18£ GBP
(47 Değerlendirme)
4.8
Pabar

Hello Sir, I have experience working with PHP and wordpress. For instance, you can have a look at http://www.dinnerwithbret.com/, which is a project in which I was part of the developer team. I can deliver what you Daha fazlası

1 gün içinde 13£ GBP
(0 Değerlendirme)
0.0