post

How to Switch Primary Sidebar to Secondary Sidebar for a Specific Page in Genesis

For one of my sites, the person wanted to use two different sidebars: one for his store and another for his blog. The rest of the site was full-width layout. So we used the two sidebars: Primary (sidebar) and Secondary (sidebar-alt). So here’s how to switch sidebars (without using Nathan’s phenomenal plugin Simple Sidebars) using functions.php.

//switch sidebars
add_action('get_header','change_genesis_sidebar');
function change_genesis_sidebar() {
    $pages = array(181);

    if ( is_page($pages)) {
        remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
        add_action( 'genesis_sidebar', 'genesis_do_sidebar_alt' );
    }
}  

This code can be easily adapted to be done based on category, archives, author, etc. See the conditional tags for more details.

post

Add Custom CSS File Based on Page Type: Front Page, Home Page, Category Page, Archive Page, 404 Page, Author Page, and Page

So I found one question that I read that asked how to have a custom CSS file per page. Here’s an easy way to add custom CSS files based on simple conditional logic in Genesis.

remove_action('genesis_meta', 'genesis_load_stylesheet'); //removes current stylesheet
add_action('genesis_meta','genesis_custom_css');
//get_bloginfo('stylesheet_url') is our normal style.css
function genesis_custom_css() {
	if (is_category())
		echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/cat_style.css" type="text/css" media="screen" />'."n";
	if (is_home() || is_front_page())
		echo '<link rel="stylesheet" href="'.get_bloginfo('stylesheet_url').'" type="text/css" media="screen" />'."n";
	if (is_archive())
		echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/arch_style.css" type="text/css" media="screen" />'."n";
	if (is_author())
		echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/auth_style.css" type="text/css" media="screen" />'."n";
	if (is_page()) //also can take $pages=array(1,2,3); adding and elseif or else at the end.
		echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/page_style.css" type="text/css" media="screen" />'."n";
	if (is_404())
		echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/page_style.css" type="text/css" media="screen" />'."n";
}