ThemeShaper Forums » Thematic

[closed]

Can't is_front_page() on filter thematic_widgetized_areas

(7 posts)
  • Started 4 years ago by stas
  • Latest reply from helgatheviking
  • This topic is resolved
  1. Hi,
    I'm trying to hide some asides from frontpage/homepage so I start editing my functions.php file. I got something like this:

    /**
     * Remove primary and secondary assides from home page
     */
    function ct_remove_widgets_from_homepage($content) {
        if(is_front_page()) {
            unset($content['Primary Aside']);
            unset($content['Secondary Aside']);
        }
        return $content;
    }
    add_filter('thematic_widgetized_areas', 'ct_remove_widgets_from_homepage');

    The code above doesn't work. I can still get both the asides. var_dump(is_front_page()|is_home()) returns bool(false) in both cases.

    Any tips?
    Thanks in advance.

    Posted 4 years ago #
  2. Hi stas,

    I dont think you can conditionally unset those areas from the array but instead conditionally control where they are displayed:

    function child_main_asides($content) {
    	$content['Primary Aside']['function'] = 'childtheme_primary_aside';
    	$content['Secondary Aside']['function'] = 'childtheme_secondary_aside';
    	return $content;
    }
    add_filter('thematic_widgetized_areas','child_main_asides');
    
    function childtheme_primary_aside() {
    	if ( !is_home() || !is_front_page() ) {
    		if (is_sidebar_active('primary-aside')) {
    			echo thematic_before_widget_area('primary-aside');
    			dynamic_sidebar('primary-aside');
    			echo thematic_after_widget_area('primary-aside');
    		}
    	}
    }
    
    function childtheme_secondary_aside() {
    	if ( !is_home() || !is_front_page() ) {
    		if (is_sidebar_active('secondary-aside')) {
    			echo thematic_before_widget_area('secondary-aside');
    			dynamic_sidebar('secondary-aside');
    			echo thematic_after_widget_area('secondary-aside');
    		}
    	}
    }

    I think this should work better for you.

    -Gene

    Posted 4 years ago #
  3. So the only solution is to overwrite the functions?!?!
    Looks like using CSS rules is much easier.
    :(

    Posted 4 years ago #
  4. Generally speaking, I prefer CSS display:none for removing individual elements from view.

    But in a case such as this where you want to be rid of large blocks of code, I think adding the conditional to the display callback function to completely remove these areas from the source code is the best route.

    I'd love to hear if anyone else has a different opinion or a better way of doing this.

    -Gene

    Posted 4 years ago #
  5. Thanks Gene.
    I followed your advice.

    Posted 4 years ago #
  6. jfverville
    Member

    Hey I was searching for this. Thanks Gene for your solution.

    Posted 3 years ago #
  7. I use the same code Gene procided... I probably stole it from one of his posts here. I don't think CSS rules are any easier than copying and pasting his code snippet.... but then, i prefer to disappear things on the back-end.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.