ThemeShaper Forums » Thematic

[closed]

The right way removing widgets on certain pages using functions.php?

(6 posts)
  • Started 3 years ago by antesark
  • Latest reply from Lenwood
  • This topic is not resolved
  1. antesark
    Member

    Topic says it all.

    My question is, how do I remove/add certain widgets on certain pages (single, mainpage, page and so on)..? All the widgets I need to remove/add are coded by hand in the same functions.php..

    Posted 3 years ago #
  2. antesark
    Member

    Added if-function to the widget code tex:

    function childtheme_sidebar_search() {
    if ( is_home() ) {
    code here..
    }
    }

    This seemed to do the trick clean..

    Posted 3 years ago #
  3. antesark
    Member

    Ok, I guess I need to check if widget is active.. otherwise site halts.

    Posted 3 years ago #
  4. antesark
    Member

    Im trolling my own post.. anyways, got it to work (prolly theres some more fancy way of doing this and feel free to post here if you know how)..

    function childtheme_sidebar_related() {
    if ( is_active_widget('childtheme_sidebar_related') && is_single() ) { ?>
    <div id="sidebar_related_posts">
    </div><!-- sidebar_related_posts -->
    <?php }
    }

    Posted 3 years ago #
  5. Danieliser
    Member

    here is what i came up with. i also have several other functions and invite you to add yours @ Wiki-4-Thematic

    function remove_widget_areas($content) {
        if ( is_home() ) {
    	unset($content['1st Subsidiary Aside']);
    	unset($content['2nd Subsidiary Aside']);
    	unset($content['3rd Subsidiary Aside']);
    	unset($content['Index Top']);
        }
        return $content;
    }
    add_filter('thematic_widgetized_areas', 'remove_widget_areas');
    Posted 3 years ago #
  6. Thanks Danieliser! I'd been trying to code this up myself when I came across this. Brilliant!

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.