Tagged: x
-
AuthorPosts
-
October 5, 2016 at 5:29 am #1203206
John CParticipantThis seem to be an on-going issue for many users and actually very confusing for many of us.
There are lots of Posts on the forum around this subject but none of which seem to work for me.
All I want is to have a sidebar that appears on the Blog ‘Posts’ themselves – NOT on the Blog Index Page, Search or Archives.
My Stack = Integrity
I have set the customiser > Layout and design > Content Left, Sidebar Right
I have set customiser > Blog > Use Global Content LayoutAppearance > Sidebars – added a ‘Blog Posts’ Sidebar to show on All Taxonomies ‘Blog’ (all my blog posts have this category selected with some additional ones too.)
The blog index shows up with a blank white space where the side bar is…I don’t want a sidebar on this page.
http://www.thewisehippo.com/blogEach blog post has no sidebar
http://www.thewisehippo.com/blog/lonely-mum-villagePlease help…it’s killing me!
Thanks
—
JohnOctober 5, 2016 at 5:44 am #1203226
John CParticipantAlso…I don’t want to have to allocate the sidebar to each individual blog post in Appearance > Sidebars
October 5, 2016 at 7:24 am #1203311
Paul RModeratorHi,
Thanks for writing in!
To achieve all that, please set your blog layout to full width then add the code below in your child theme’s functions.php file.
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 = 'full-width'; } 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( 'post' ) ) { $layout = 'content-sidebar'; } return $layout; } add_filter( 'ups_sidebar', 'fix_category_sidebar' ); function fix_category_sidebar($default_sidebar ) { //var_dump( get_intermediate_image_sizes() ); $categories = get_the_category(); $post_categories = array(); if(is_array($categories)) { foreach ( $categories as $category ) { $post_categories[] = $category->term_id; } } $sidebars = get_option( 'ups_sidebars' ); if(is_array($sidebars)){ foreach ( $sidebars as $id => $sidebar ) { if(isset($sidebar['taxonomies']) && is_array($sidebar['taxonomies'])){ foreach($sidebar['taxonomies'] as $t_id => $tax) { if(in_array($t_id,$post_categories)) { return $id; } } } } } return $default_sidebar ; }Hope that helps.
October 5, 2016 at 7:43 am #1203334
John CParticipantHi Paul
Thanks for taking the time to reply. I have done that but it hasn’t worked 🙁 – The ‘Blog Index’ is now full-width as are the blog pages also.
Thanks
—
JohnOctober 5, 2016 at 8:43 am #1203412
Paul RModeratorHi John,
I can see the sidebar in the code of your posts but it is not showing up because of this css code.
.single-post .x-sidebar { display: none; }Please remove it in your child theme style.css
Thanks
October 5, 2016 at 10:20 am #1203547
John CParticipantPaul thanks for spotting that, there was another little bit of css too that need removing. But its working now.
Cheers
J
October 5, 2016 at 10:34 am #1203566
Prasant RaiModeratorYou are most welcome. 🙂
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1203206 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
