Is This Really Simple PHP Code Correct?

by lovboa Banned
3 replies
<?php $post_counter=0; ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>

<?php
$post_counter++;
if ($post_counter == 2 || $post_counter == 4) { ?>

<div style="float:right; margin-right:25px;">
adsense code is placed here
</div>
<div class="clear"></div">
<?php } ?>

<?php endwhile; ?>
<?php endif; ?>



It works fine when I have only $post_counter == 2

But when I add the ... || $post_counter == 4
It works, but the footer becomes distorted. The footer usually has no background, but when I add that part, it becomes part of the main container with the white background.

I'm confused could somebody help me?

Thank you.
#code #correct #php #simple

Trending Topics