Support » Plugins » Ads only in a few posts

  • Hello,

    I’m looking for a plugin to insert adsense ads just in a few posts.
    But all plugin I found inserts ads in ALL post, when the possibility to exclude some of them…

    So, do you know a plugin to do what I need? It could be as a normal ads, or as a wigted showed justs in a few posts.

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter argie01

    (@argie01)

    Yes, I did it. But I’m looking for a plugin, for example for to use adsense.

    you could use shortcode;

    in functions.php, add something like, for instance to show adsense:

    function show_ads() {
        return '<div class="adsense">
    <!-- start of ad code -->
    
    <script type="text/javascript"><!--
    google_ad_client = "pub-1234567890";
    /* my_adsense */
    google_ad_slot = "123456789";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    
    <!-- end of ad code -->
        </div>';
    }
    add_shortcode('adsense', 'show_ads');

    and in style.css, you could use .adsense { ..... } to format the adsense area.

    and in the few posts, enter [adsense] into the text of the post, on its own line, where you want to show the ad.

    Thread Starter argie01

    (@argie01)

    Thank you!! that code works fine!!
    But, is there a way to add “adsense” in my post as a comment, instead of use the brackets?

    ad the codes to your comments.php file instead of functions.php

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Ads only in a few posts’ is closed to new replies.