Skip to:
Content
Pages
Categories
Search
Top
Bottom

Inserting ads between posts.


  • sureshdrim
    Participant

    @sureshdrim

    Hello Guys,

    Is there any way to insert some code between/after every fixed number of posts.

    For Example:If I want to display google Ads after every fourth or sixth post on topic.php page,where can I put Ads code.

    Any help will be really appreciated !!

Viewing 7 replies - 1 through 7 (of 7 total)

  • kevinjohngallagher
    Member

    @kevinjohngallagher

    Line 33 of topic.php has the for loop that goes through all the posts.

    Insert your code there :)


    sureshdrim
    Participant

    @sureshdrim

    @ kevinjohngallagher

    Hey dude you are genius.My problem is solved.

    But just a small doubt-I made a counter (initial value=0) which will count number of posts in foreach loop (Line 33 of topic.php),if counter is equal to 4 – code for ads – reset counter to 0,else increment counter by 1.This works.Ads are displayed after every 4 posts.But only first two ads are visible rest of the ads are invisible i.e a white space is felt at the place of ads after second ad.

    I just want to ask u,is there any policy of google which doesn’t allow to put ads in a loop or doesn’t allow to display same ad repeatedly on a page ? Any idea about this ?


    kevinjohngallagher
    Member

    @kevinjohngallagher

    <blockequote>

    you are genius

    Ha, thanks alot, but i can’t tell you how wrong that is ;-)

    I’ve no idea about Google Ad’s i’m afraid.

    Initially, I’d output a div with a border on it to make sure your code is working spot on, and then take it from there :)


    sureshdrim
    Participant

    @sureshdrim

    Thank you kevinjohngallagher..

    as far as I know google only allow 3 ad units per page, not sure about link units.

    If you are displaying a goodle ad in your header, sidebar or anywhere else, this is probably the reason only 2 are displaying in the loop.


    zaerl
    Participant

    @zaerl


    aidecms
    Participant

    @aidecms

    Hi, would you please give me the code to count post and displays your ad ?

    Thank you very much

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar