Sidebar on a blogpost

Hi

I wonder how I get the sidebar on blogpost.

//Andreas

Hi Andreas,

I am not sure what you are talking about by Blogspot, but if you are talking about your main blog page which you have set in WordPress > Settings > Reading, then you can go to X > Theme Options > Layout and Design and make sure you set the site to have a sidebar:

Then, go to X > Theme Options > Blog and make sure that the layout for the blog is set to the global settings:

After that, you can go to Appearance > Widgets and assign the widgets you want to Main Sidebar widget area:

If you still have problems, get back to us with a more detailed explanation of the problem at hand with the link to your website.

It is recommended that you check our KB overview page which has valuable information regarding the Theme Options and how to use the theme.

Thank you.

Hi

When I do this I got a sidebar on every page. I only want it on a blogpost-page.

//Andreas

Hi There,

Please follow these step:

  1. Install and activate the child theme first: https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57

  2. Add the following code under functions.php file locate 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_home() ) {
		$layout = 'content-sidebar';
	}

	return $layout;
}
  1. Create a sidebar for the blog page under Appearance > Sidebars:

Hope it helps :slight_smile:

Hi

That works fine. If I want I on on a single blog-post, not the index-side.

//Andreas

Hi There,

Please find this code:

if ( is_home() ) {
	$layout = 'content-sidebar';
}

And change to this:

if ( is_singular( 'post' ) ) {
	$layout = 'content-sidebar';
}

Regards!

Perfect! Thanks so much for the help!:+1::grin::pray:t4:

1 Like