Add sidebar to main Forums page

Hello there,

I was searching the forums here to find the right way to add a sidebar to the main forums page and I will appreciate your help. What I’d like to achieve is this layout: http://demo.theme.co/integrity-1/forums/ . Right now I have my Forums page in full-width. The rest of the sub-forums and topics have sidebar, but the the main forums page.

Thanks in advance

Hello @sparoministries,

Thanks for writing in! :slight_smile:

You may need to go your forums page, and change the template to: Layout - Sidebar Left, Content Right.

Selecting this template will enable the default sidebar that is the same as what is on the sub-forums.

Hope this helps.

Hi @jumar

Thanks for your prompt reply!

As you probably know the /forums page is generated automatically when you install and configure bbPress.
However I created a page in wp-admin, named it “Forums” and the page got that slug, but when I change the layout template nothing happens at the front. Please see the attached file.

Any idea what else could be done?

Thanks a lot!

Hi There,

Please add the following code under functions.php file locates in your child theme:

function x_get_content_layout() {

		$content_layout = x_get_option( 'x_layout_content' );

		if ( $content_layout != 'full-width' ) {
			if ( is_home() ) {
				$opt    = x_get_option( 'x_blog_layout' );
				$layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
			} elseif ( is_singular( 'post' ) ) {
				$meta   = get_post_meta( get_the_ID(), '_x_post_layout', true );
				$layout = ( $meta == 'on' ) ? 'full-width' : $content_layout;
			} elseif ( x_is_portfolio_item() ) {
				$layout = 'full-width';
			} elseif ( x_is_portfolio() ) {
				$meta   = get_post_meta( get_the_ID(), '_x_portfolio_layout', true );
				$layout = ( $meta == 'sidebar' ) ? $content_layout : $meta;
			} elseif ( is_page_template( 'template-layout-content-sidebar.php' ) ) {
				$layout = 'content-sidebar';
			} elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) {
				$layout = 'sidebar-content';
			} elseif ( is_page_template( 'template-layout-full-width.php' ) ) {
				$layout = 'full-width';
			} elseif ( is_archive() ) {
				if ( x_is_shop() || x_is_product_category() || x_is_product_tag() ) {
					$opt    = x_get_option( 'x_woocommerce_shop_layout_content' );
					$layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
				} else {
					$opt    = x_get_option( 'x_archive_layout' );
					$layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
				}
			} elseif ( x_is_product() ) {
				$layout = 'content-sidebar';
			} elseif ( x_is_bbpress() ) {
				$opt    = x_get_option( 'x_bbpress_layout_content' );
				$layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
			} elseif ( x_is_buddypress() ) {
				$opt    = x_get_option( 'x_buddypress_layout_content' );
				$layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
			} elseif ( is_404() ) {
				$layout = 'full-width';
			} else {
				$layout = $content_layout;
			}
		} else {
			$layout = $content_layout;
		}

		if ( is_singular( 'forum' ) || is_post_type_archive( 'forum' ) ) {
			$layout = 'content-sidebar';
		}

		return $layout;

}

Hope it helps :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.