<?php $post_counter=0; ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?>
Is This Really Simple PHP Code Correct?
4
<?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.
<?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.
- SteveSRS
- [ 1 ] Thanks
- lovboa Banned
- [ 1 ] Thanks
- prince55l
Next Topics on Trending Feed
-
4