Search code examples
wordpressloopsadsposts

putting code in wordpress category page


I am using wordpress.
I am using double colums to show my posts.
I just think to show ads in between my 2 and 3 posts. e.g

post 1 | post2
Ad will show here
Post3 | Post 4

But as my theme is looping 2 posts so when i am placing

 <?php if ($count == 2) : ?>
Ad will show here
<?php endif; $count++; ?>  
before php endwhile
What i am getting is

post 1 | post2
Ad will show here | Ad will show here
Post3 | Post 4

My code is alos turned into two.

It is solved now. i had same template part for showing recent posts in sidebar that's why it was showing two times.

Regards


Solution

  • <?php if ($count == 2) : ?>
    Ad will show here
    <?php  $count++; endif; ?>  
    

    This is not the exact code for you to copy and paste. what i'm trying to show is that you are incrementing the $count variable after the endif; (actually don't know where that endif loop started) try to write more detailed code that you are using currently.