Support » Themes and Templates » Add adsense after more tag only on post

Viewing 8 replies - 1 through 8 (of 8 total)
  • esmi


    Forum Moderator

    Add the adsense code to your theme’s single.php file only.

    yes, but how to display after the more tag ?



    Forum Moderator

    in single.php, instead of the_content(); try to use:

    $story = get_the_content();
    $story = explode('<span id="more',$story);
    $first_part_of_story = $story[0];
    $second_part_of_story = $story[1];
    $first_part_of_story = apply_filters('the_content', $first_part_of_story);
    echo $first_part_of_story;
    if ($second_part_of_story) {
       echo 'here adsense code';
       $second_part_of_story = explode('</span>',$second_part_of_story);
       $second_part_of_story = apply_filters('the_content', $second_part_of_story[1]);
       echo $second_part_of_story;
    } ;

    thank’s alchymyth it work

    Useful code… 🙂


    I’m using this code on one of my websites, but I’m having a problem. When I use plugins that adds something to the bottom of my post, it shows in the bottom of the post, but also after the more tag (in the middle of the post).

    Is there someway to modify this code to prevent that from happening?

    // Jens.



    Forum Moderator

    try this new approach – without the need to edit single.php – i.e. leave the_content() as it is:

    it uses a filter function ( and pops the ad code right into the more span in single post:

    Thanks a lot, that’s perfect!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Add adsense after more tag only on post’ is closed to new replies.