The MU forums have moved to WordPress.org

how to add code to sidebar widget by using add filter? (5 posts)

  1. gmchun
    Member
    Posted 14 years ago #

    Hai,
    i just started using wp-adsense for wordpress mu where it forced ads at each post content.

    I understand by using following code and i can add my google adsense at each post.But how i want to add at side bar widget only?
    add_filter('the_content', 'insert_adsense_code');

    What i should or replace the_content so i can forced ads at sidebar widget also?

    Thanks first

    Regards,
    Wallace

  2. DeannaS
    Member
    Posted 14 years ago #

    There isn't a sidebar filter. Sidebars are technically a design element, and they're not required for a WPMU site to work. Most themes, however, do you a function call to get their sidebars. It's called "get_sidebar()" and there is an action hook in it:
    do_action( 'get_sidebar', $name );

    It comes at the top of the sidebar, before it processes any other code. So, you could write a plugin that hooks into that action hook to display code.

  3. gmchun
    Member
    Posted 14 years ago #

    DeannaS,
    Ok.I will try it.But i can control to left or right side?

    Thanks.

    Regards,
    Wallace

  4. DeannaS
    Member
    Posted 14 years ago #

    Um, the sidebar placement in the html controls left or right side. If you have more than one sidebar, you'd called add action on that sidebar's name.

  5. gmchun
    Member
    Posted 14 years ago #

    DeannaS,
    And also how about front page?Because when i was using add filter with the_content.It was only show my code at each single post.
    If i want my code was appear also at front pages,what i should put at add filder?

    Please advice.
    Thanks

    Regards,
    Wallace

About this Topic