WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Mystique Theme vs adsense banners (8 posts)

  1. Driezzie
    Member
    Posted 3 years ago #

    @ Admin :

    Is there a way to implate adsense banners beneath every post ? Can I use “[ad code=4 align=center]” for this ? I do not want to type it beneath every post.

    Thanks

  2. Driezzie
    Member
    Posted 3 years ago #

    anyone ?

  3. digitalnature
    Member
    Posted 3 years ago #

    advanced > user functions:

    function insert_post_ads($content){
      $content .= do_shortcode("[ad code=4 align=center]");
      return $content;
    }
    if(is_single() || is_page()){
      add_filter('the_content', 'insert_post_ads', 4);
      add_filter('get_the_excerpt', create_function('','remove_filter("the_content", "insert_post_ads", 6); return;'), 5);
    }
  4. Driezzie
    Member
    Posted 3 years ago #

    Thanks for your response!

    I pasted my adsense code in Ad code #4 and I also pasted the code you copied above in my user functions but nothing happens when I create a new post ?

  5. digitalnature
    Member
    Posted 3 years ago #

    this one should work:

    <?php
    
    function insert_post_ads($content){
      if(is_single() || is_page()) $content .= do_shortcode("[ad code=4 align=center]");
      return $content;
    }
    
    add_filter('the_content', 'insert_post_ads', 4);
    add_filter('get_the_excerpt', create_function('','remove_filter("the_content", "insert_post_ads", 6); return;'), 5);
  6. Driezzie
    Member
    Posted 3 years ago #

    Thank you very much, everything works fine now.

  7. pooruncle
    Member
    Posted 3 years ago #

    digitalnature,

    This works, but only for single post view. How to get the ad to show up for all views? My Mystique setting is to display the complete post in all views. Thanks.

  8. Driezzie
    Member
    Posted 3 years ago #

    I'd like to posts the adsense banner BENEATH the posts's TAGS so the design will look more cleaner. Don't really know what to adjust in the code showed above.

Topic Closed

This topic has been closed to new replies.

About this Topic