WordPress.org

Ready to get started?Download WordPress

Forums

Affiliate ads - adSense in the sidebar (3 posts)

  1. Fundamental Charlie
    Member
    Posted 5 years ago #

    I heard that the easiest way for a non-techno, (boy is that me!), to set ads into the sidebars is to write a simple text widget and put my HTML in it and then assign it in the 'manage widgets' area.

    1 - Is this true?
    2 - Where do you code widgets?
    3 - Is there somewhere I can knock off a generic that will do this?
    4 - Since I'm such a newbie, what do I need to know about this, that I don't even know enough to ask?

    I am using a widgeted theme.
    Any help would be greatly appreciated.

  2. mrmist
    Forum Janitor
    Posted 5 years ago #

    yeah you can write your own widget, or there is a adsense plugin knocking about somewhere.

    If you write your own, you can hack it into the theme's sidebar by modifying functions.php to include something like

    <?php
    function widget_showgoogleads($args) {
        extract($args);
    echo $before_widget;
    echo $before_title
                    . 'Ads by Google'
                    . $after_title; ?>
     .... Put your advert code block here ....
           <?php echo $after_widget; }
    register_sidebar_widget('Ads by Google',
        'widget_showgoogleads');
    
    ?>

    Which is pretty much what I do, so it definitely works... (Probably better ways of doing it though as that pretty much keeps it in the sidebar all the time.)

  3. Fundamental Charlie
    Member
    Posted 5 years ago #

    Will this put it in every page or only on one?

    Do you put it anywhere in 'functions.php' or is there some protocol for that too?

Topic Closed

This topic has been closed to new replies.

About this Topic