WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to integrate adsense to only first recent post? (3 posts)

  1. Sxperm
    Member
    Posted 7 years ago #

    I already have adsense on top nav bar and right nav bar and I just want to integrate another one adsense to my post. However, I just need to integrate adsense on recent post, when I updated the new post, adsense will be shown on my latest post automatically and I do not have to edit each new post to integrate adsense and delete the old one previous manually. Is there a plug-ins that can do this? I searched here already but did not found thread related to this.

  2. iLobster
    Member
    Posted 7 years ago #

    OK,
    open the index.php file of the theme you're using.
    somewhere on the top, add this:

    <?php
    $adsense = '<em>put your  adsense code here</em>';
     ?>

    replace "put your adsense code here" with your actual adsense code

    now, find a line that contains <?php the_content
    under it add

    <?php
     echo $adsense;
    $adsense = '';
    ?>

    You should be done now

  3. Sxperm
    Member
    Posted 7 years ago #

    Thank you very much iLobster. :D It's work great!!

Topic Closed

This topic has been closed to new replies.

About this Topic