Skip to:
Content
Pages
Categories
Search
Top
Bottom

Google Adsense

  • @ry4nanderson

    Member

    Hello-

    I’d like to add some Adsense ads in either my header or below the the forum listing on the main page. Pasting Google’s code in the header doesn’t seem to play nicely. Any ideas? Sample syntax, perhaps, from those who have already done it?

    Thanks!

Viewing 19 replies - 1 through 19 (of 19 total)
  • @ear1grey

    Member

    I’d advise against using header.php, because your header is also shown on non-content pages such as 404’s; something which is disallowed in the adsense T’s and C’s.

    I did it by writing a small plugin, which you’re welcome to. Just create a my-plugins folder within your bbpress root folder, paste the text below into the file and save it as bbpress-adsense.php, upload it to your server and an advert will appear on every topic.

    From there on you have the basics for changing the advert to whatever you prefer.

    <?php

    /*

    Plugin Name: Simple bbPress Adsense

    Plugin URI: http://boakes.org/talk/tags/bbpress-adsense

    Description: An plugin that includes an adsense advert just above the content on the topic page.

    Author: Rich Boakes

    Version: 0.1

    Author URI: http://boakes.org

    License: GPL

    */

    class bb_adsense {

    function wide_advert() {

    ?>

    <div class="bbpress-adsense" style="text-align:center;">

    <!-- Paste your advert below this line -->

    <script type="text/javascript"><!--

    google_ad_client = "pub-9050338238897291";

    google_ad_width = 728;

    google_ad_height = 90;

    google_ad_format = "728x90_as";

    google_ad_type = "text_image";

    google_ad_channel = "5984252204";

    google_color_border = "FFFFFF";

    google_color_bg = "EEEEEE";

    google_color_link = "990000";

    google_color_text = "333333";

    google_color_url = "999999";

    //--></script>

    <script type="text/javascript"

    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">

    </script>

    <!-- Paste your advert above this line -->

    </div>

    <?php

    } // function wide_advert

    } // class bb_adsense

    // adds the footer so the javascript is loaded

    add_action('under_title', array('bb_adsense','wide_advert'));

    ?>

    @null

    Member

    I like this, but I want my adds to show AFTER each first post.

    So like:

    Post: Hi I need help bla bla

    google adsence

    First reply: do like this bla bla

    Sec reply: or like bla bla

    Etc

    How to do that?

    And is there also a page to maintain your adsence? Like how many click etc in the admin area?

    Greetz

    @ear1grey

    Member

    Hi Null, to do that you need to change your template a bit and create a new hook, which is dead easy, and a testament to the flexibility of the event model that underpins both WP&bb.

    1. Copy topic.php from bb-templates into my-templates (you may need to create this folder).
    2. Find the for loop near line 29 – it will read something like this: <?php foreach ($posts as $bb_post) : $del_class = post_del_class(); ?>
    3. Immediately before it (outside the loop, but inside the <?php) add the line $need_to_show_ad=true;
    4. Then change the line <?php bb_post_template(); ?> to read <?php bb_post_template(); if ($need_to_show_ad) { do_action('showadvert'); $need_to_show_ad=false; } ?>
    5. Finally, change the action in the plugin so it fires on your newly created hook add_action('showadvert', array('bb_adsense','wide_advert'));

    … and an admin page? Maybe when bbPress matures!

    @jakey

    Member

    I almost understood that last part.

    -edit-

    oops! read it again and it made sense. thanks.

    @disier

    Member

    When i post, edit or delete somethin i get this error

    Warning: Cannot modify header information – headers already sent by (output started at /home/disiern/public_html/enblogeo/foro/my-plugins/bbpress-adsense.php:39) in /home/disiern/public_html/enblogeo/foro/bb-includes/pluggable.php on line 160

    how can i solve this??

    @ear1grey

    Member

    Hi Disier, did you make any other changes other than add the plugin as above? Do you have other plugins installed? Which hook did you use (i.e. what does your add_action line say)?

    @disier

    Member

    im using the latest version 0.75, and the only plugin the i have is allow image.

    I uninstalled right now because when my friend register in my board and try to login we get that error and canĀ“t login i will delete allow image to see if that plugin is the one of the trouble

    @disier

    Member

    Sorry I fix it the problem was here:

    a the end of the plugin

    <?php

    } // function wide_advert

    } // class bb_adsense

    // adds the footer so the javascript is loaded

    add_action(‘showadvert’, array(‘bb_adsense’,’wide_advert’));

    ?>

    in the last line was needing an space after array(‘bb_adsense’,’wide_advert’)); i dint give an space so the ?> was giving the problem thanks anyway

    @beer

    Member

    The add_action( ‘under_title’ .. ) part has me curious. Where does the ‘under_title’ come into play? I was trying to find it in my bbpress code. I want to add a wide 250×250 block for example under ‘Add this topic to your favorites’ on the left of the tags column.

    http://www.grindhouse.com/forums/topic/26?replies=1

    How can I accomplish this?

    @jeremykuno

    Member

    This plugin causes an error when I try to delete users. I get the following message:

    Warning: Cannot modify header information – headers already sent by (output started at /home/jkuno/public_html/seattlecondoreport/forums/my-plugins/bbpress-adsense.php:43) in /home/jkuno/public_html/seattlecondoreport/forums/bb-includes/pluggable.php on line 168

    Any ideas?

    @fel64

    Member

    Look for blank lines or spaces before the starting <?php and after the ending ?> as they can cause that problem.

    @geld_lenen

    Member

    Can’t get the system working on my blog, other colors?

    I did everything from earigrey’s post and it does nothing. My main concern is since he asks for it to be put in my-template folder how is the software supposed to know that those files are there. So i just replaced the topic file in the template directory. How do i reference the adsense code so the page knows to look there?

    @mark8barnes

    Member

    @hypotheekrente

    Member

    thanks @mark8barnes

    It is indeed very nice, just tried it.

    @lenen-nl

    Member

    I’m a bit scared messing around with the adsense code.

    @webdesign-kapeljosie

    Member

    Mmm, i was looking for this plugin, but this one isn’t working anymore:

    http://boakes.org/talk/tags/bbpress-adsense

    @phaniraj01

    Member

    adsense injection is a great plugin , when showing ads, its displaying “array” and ads

    ie

    array

    google adsense ads

    Thanks,

    phani

    @xtremetoonz

    Participant

    Is it possible to do a membership model where a paying user can have no ads?

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