Tagged: x
-
AuthorPosts
-
September 8, 2016 at 7:56 pm #1167316
Hello X
I have gone through several search results pages trying to find a solution for adding a sidebar to individual blog posts but i can’t seem to find a working solution for my case.
Since i only want the sidebar on the individual blog posts, I cannot use the global settings in the customizer because that will make changes to all posts and pages. I hence tried adding a sidebar via Appearance>Sidebars which seems also not to work after selecting blog display options.
I have also tried to manage my sidebars and created a new sidebar called “Blog Sidebar” and removed any widgets from the main sidebar and only left widgets in the new sidebar “Blog Sidebar” This works partially because it now creates an unwanted space for the empty widget area for other pages and shows for the “Blog Sidebar” This is also inadequate because it only works for the blog posts page(which is a custom link) but not the individual blog posts.
I have also activated the Masonry style which is a very good feature but does not entirely help because it also does not apply to the individual blog posts.
I also can’t fix this issue using template options in page attributes because my blogs are not pages but posts which appear not to have this option.Could i be skipping something or is there another way to do this? Sorry for the long post, i just wanted to ensure that i gave all my particulars.
My PHP version, WordPress version, X theme version, Cornerstone and all plugins are up to date.
Website link: http://www.citymall.co.keI will appreciate any assistance.
David
September 8, 2016 at 7:59 pm #1167317This reply has been marked as private.September 9, 2016 at 1:59 am #1167620Hi,
Yes, you are correct it’s not an option.
To achieve that, add the code below in your child theme’s functions.php
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; }
You may add it after this line
// Additional Functions
// =============================================================================Hope that helps.
September 9, 2016 at 4:02 am #1167728Hello
Im looking at the functions.php file and i have no idea where or how to place that code. I know that if i mess up anything to do with my theme’s stylesheet i’m done and i definitely have no idea how to remedy it.
Kindly assist
September 9, 2016 at 5:04 am #1167795Hi David,
Kindly install and activate a child theme first.
Then Navigate to Appearance > Edit
Please see screenshot – http://screencast.com/t/VLhpOec3
September 9, 2016 at 9:18 am #1168011Hello
I already have a child theme installed and the website is currently on the child theme.
September 9, 2016 at 1:23 pm #1168366Hi Therem,
You need to access your website FTP or Cpanel and go to Wp-Content/Themets/X Child/
Inside you will find the file, download it, use notpad to add the changes, and upload and replace.
Hope it helps
Joao
September 10, 2016 at 4:02 pm #1169519Hello
First i’d like to apologise because i had misunderstood Paul’s reply,but i finally got it and the FTP method from Joao worked fine.
The sidebar appears on individual blog posts but just as a space. However i found out that i can activate the widgets to appear by ticking on each post which seems to work fine.
The sidebar widget doesn’t appear on the main blog page but i turned on the Masonry feature which makes it look fine and i am content with the results.
However, it would be really convenient if the widgets appeared on the sidebar automatically for each blog post created instead of having to select each blog post manually in “Manage Sidebars”.
Thank you so much X for the wonderful support.
David
September 11, 2016 at 2:23 am #1169856Hello David,
You can override the sidebar settings and set the name of your desired sidebar to appear on single posts. Since you already have your child theme active and ready, please insert this following code in your child theme’s functions.php file.
function assign_custom_sidebar($sidebar){ if ( is_single() ){ return 'ups-sidebar-sample'; } return $sidebar; } add_filter( 'ups_sidebar', 'assign_custom_sidebar');
Please do not forget to replace the sidebar ID ‘ups-sidebar-sample’ with your own sidebar ID.
Hope this helps.
September 11, 2016 at 6:58 am #1170051Hello X
I have added the code suggested by Rue Nel and it partially works as it creates the sidebar space automatically on each new blog post created. Is there a way it can also automatically show the widgets in the sidebar without manually selecting each blog post?
David
September 11, 2016 at 7:37 am #1170071Hey David,
Regretfully this isn’t a feature offered by X. It could be possible with custom development, but this would be outside the scope of support we can offer. You might want to contact our trusted partners who caters X setup and customization needs. Please see https://community.theme.co/custom-development/.
Thanks for understanding. Take care!
September 11, 2016 at 7:48 am #1170086Hello X
Noted.
Thank you for your assistance.
September 11, 2016 at 8:15 am #1170099You’re welcome.
-
AuthorPosts