Tagged: x
-
AuthorPosts
-
April 2, 2016 at 5:44 pm #864103
Hi,
I’ve read through the forum on this topic, but not sure if this functionality has been included in the latest release or not. I’d like my individual blog posts to have the same custom sidebar as my blog index page – which is a different sidebar than the “main” sidebar found on my homepage and other “pages.”I tried the 2nd to last fix found on the link below to adjust my child theme code, but it didn’t work. I am able to “manually” check each post to get the custom sidebar to appear, but that is way too time consuming to have to do that every time a new post is added.
https://community.theme.co/…/automatic-sidebar-display-on-posts/
How can I automatically include the same custom sidebar found on my blog index page on each individual post? Thanks much!
website: terrakonmarketing.com
Latest versions of WP, X, and Cornerstone (although still using Visual Composer to update pages/posts)April 2, 2016 at 6:54 pm #864133Follow up…Per the previous link/forum post from Oct ’14, I copied the wp-sidebar.php file from my Renew theme to my Renew child theme and edited as below…Again, no result – I still get the “main” sidebar on individual posts…
I renamed ‘blog’ in the posted example code to the ID of the sidebar I wish to show on each individual post…’ups-sidebar-ppc-blog-main-sidebar’
<?php
// =============================================================================
// VIEWS/RENEW/WP-SIDEBAR.PHP
// —————————————————————————–
// Sidebar output for Renew.
// =============================================================================?>
<?php if ( x_get_content_layout() != ‘full-width’ ) : ?>
<aside class=”<?php x_sidebar_class(); ?>” role=”complementary”>
<?php if ( is_singular(‘post’) ) : ?>
<?php dynamic_sidebar( apply_filters( ‘ups_sidebar’, ‘ups-sidebar-ppc-blog-main-sidebar’ ) ); ?>
<?php elseif ( get_option( ‘ups_sidebar’ ) != array() ) : ?>
<?php dynamic_sidebar( apply_filters( ‘ups_sidebar’, ‘sidebar-main’ ) ); ?>
<?php else : ?>
<?php dynamic_sidebar( ‘sidebar-main’ ); ?>
<?php endif; ?>
</aside><?php endif; ?>
April 3, 2016 at 3:42 am #864495hello There,
Thanks for writing in! To better assist with this issue, would you mind providing us the url of your site with login credentials so we can take a closer look and fix the issue? This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.
To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP Hostname
– FTP Username
– FTP PasswordDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thank you.
April 4, 2016 at 4:44 pm #866630This reply has been marked as private.April 5, 2016 at 5:19 am #867409Hi Rob,
If you want to dynamically add different sidebar for single post page, it could be possible using custom code. Above code on your second reply should work. Can you try deleting/purging cache? We might be seeing a cache content. Try again after that. If the issue still exists after that, please do give us FTP access so we can check further.
Always,
XApril 5, 2016 at 8:12 am #867598This reply has been marked as private.April 5, 2016 at 8:48 pm #868449Hi Rob,
Thank you for the credentials.
It is not working because the location of wp-sidebar.php file is wrong. You have uploaded it in /public_html/wp-content/themes/x-child-renew. It should be in /public_html/wp-content/themes/x-child-renew/framework/views/renew. I have uploaded it on the correct folder and as you can see on the screenshot below it is showing the correct sidebar now.
You may now delete wp-sidebar.php file from this folder /public_html/wp-content/themes/x-child-renew.Cheers!
April 6, 2016 at 5:53 am #868979Awesome! Thanks for the help!
April 6, 2016 at 6:15 am #869009Oops…Perhaps I’m missing something again, but it APPEARS adding this code to enable the custom sidebar on the individual blog posts has removed the same custom sidebar from the blog index page. Is this expected? I still have the “Enable sidebar on blog index page” checked on the appearance/sidebar, but the sidebar on the blog index page now defaults to the “primary” sidebar. I would like the custom sidebar PPC Blog Main Sidebar (ups-sidebar-ppc-blog-main-sidebar) to still appear on the blog index page – same sidebar as the individual posts. How can I do that? Thanks, again.
April 6, 2016 at 9:30 am #869379Hi,
To display that sidebar in your blog index, you can add this in your child theme’s functions.php file.
add_filter( 'ups_sidebar', 'blog_sidebar', 99999 ); function blog_sidebar ( $default_sidebar ) { if (is_home()) { return 'ups-sidebar-ppc-blog-main-sidebar'; } return $default_sidebar; }
Hope that helps
April 6, 2016 at 11:03 am #869568Hi,
I added the suggested code to the functions.php file at public_html/wp-content/themes/x-child-renew/functions.php
and it does not appear to work. With code in place, I also tried checking and unchecking the “Enable sidebar on blog index page” for the sidebar several times too, but still no change.April 6, 2016 at 3:22 pm #870029Hi,
Another unwanted side effect of using the sidebar code suggested/used above is that the details of the individual post (e.g. author, publish date/time, etc.) no longer appear with the post…How do I go about fixing this issue as well? Thanks, again…
April 6, 2016 at 3:24 pm #870030Hi Rob,
Please change the provide code to this,
add_filter( 'ups_sidebar', 'blog_sidebar', 99999 ); function blog_sidebar ( $default_sidebar ) { if ( is_home() || is_singular('post') ) { return 'ups-sidebar-ppc-blog-main-sidebar'; } return $default_sidebar; }
Though, I still can’t see the layout sidebar from my end. Please add this code too,
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' ) ) { return 'content-sidebar'; } return $layout; }
Hope this helps.
April 6, 2016 at 4:16 pm #870097Hi,
I added the revised code and the new code above at /public_html/wp-content/themes/x-child-renew/functions.php
Nothing happened…Still no ups-sidebar on index page AND the individual blog data (author, time stamp, etc.) still does not appear. Again, I had both of these items working until the suggested ups-sidebar code was added to get the sidebar on the individual posts…Thanks, again, Rob
//Add Blog Sidebar to Blog Index Page add_filter( 'ups_sidebar', 'blog_sidebar', 99999 ); function blog_sidebar ( $default_sidebar ) { if ( is_home() || is_singular('post') ) { return 'ups-sidebar-ppc-blog-main-sidebar'; } return $default_sidebar; } 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' ) ) { return 'content-sidebar'; } return $layout; }
April 7, 2016 at 12:40 am #870609Hi Rob,
I was able to fix it by removing wp-sidebar.php in your child theme.
The code in your functions.php should do the trick.
I have also enabled post meta in your blog.
Kindly check on your end.
Thanks
-
AuthorPosts