• Resolved gabrielsolomon7

    (@gabrielsolomon7)


    Hello,

    Using the oxygen theme. I have searched the forums for some hours with no luck yet.

    I need to hide the right sidebar on certain pages of my site. I have created a child theme and a custom page template that will be used for those pages that require no right sidebar.

    Does anyone know how to write the code for my functions.php file that will not call the right sidebar with my custom page template AND allow my content to flow to the right edge of the page?

    Keep in mind that I want this functionality on certain pages, hence the custom page template.

    Thanks! G

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m interested! hands up

    @esse3 – please stop posting in other people’s threads – that’s not how these forums work. If you can’t wait for help, consider hiring someone.

    Thread Starter gabrielsolomon7

    (@gabrielsolomon7)

    I got some help on this from makapa in another thread. I made the following entry to my functions.php file:

    add_filter( 'sidebars_widgets', 'oxygen_disable_sidebar_right' );
    
    function oxygen_disable_sidebar_right( $sidebars_widgets ) {
    
    	global $wp_query;
    
    	    if ( is_page_template( 'ModifiedBookmarks.php') ) {
    		   	$sidebars_widgets['secondary'] = false;
    	    }
    
    	return $sidebars_widgets;
    }
    
    	add_action( 'sidebar_widgets', 'oxygen_disable_sidebar_right', 11 );

    That got rid of the sidebar. To get my content to flow to the right, I then looked inside of that same template and found the content div ID of the material in question. I renamed <div id=”content”> to my own name <div id=”2CL-content”> (for two columns with sidebar on left; I wanted to make the name specific and unique but not to complex). Following that, I was able to add the code below to my style.css:

    /* #2CL-content: For allowing text to flow to the right of the page on pages where there
    are only two columns with the sidebar on the left.*/
    
    #2CL-content {
    	float: left;
    	width: 100%;
    	margin: 0 0 30px;
    }

    I have begun adding notes to my modifications along the way so its easier to keep track of my work. When I am done or feel more comfortable, I can then take out those notes if necessary.

    Thanks to all who posted on other threads and helped me solve this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide Right (secondary) sidebar on certain pages’ is closed to new replies.