Learndash page sidebar

Hi I tried implementing the below code from another form post, which works and shows the sidebar on my Learndash pages, however once I implement it, the blog sidebar and individual blog post sidebars disappear.

Will send my login details in a secure note.

add_filter('x_option_x_layout_content', 'add_sidebar_learndash',999);
function add_sidebar_learndash($layout) {  
    if ( 'product' || 'sfwd-courses' || 'sfwd-lessons' || 'sfwd-quiz' || 'sfwd-topic' || 'sfwd-certificates' == get_post_type() )  {      
       $layout = "content-sidebar";
   }
  return $layout;
}
function assign_my_sidebar($sidebar){ 
       if ( 'product' || 'sfwd-courses' || 'sfwd-lessons' || 'sfwd-quiz' || 'sfwd-topic' || 'sfwd-certificates' == get_post_type() )  {      
           return 'ups-sidebar-course';        
       }    
  return $sidebar;
}
add_filter( 'ups_sidebar', 'assign_my_sidebar');

Hi William,

Please add another Sidebar with the same widgets and information, and assign it for the blog normally using the proper settings given in the article below:

That will act as the one which will be available for the blog pages and the one you used the code will work on learndash related pages. You can have both of them the same in this case, but alternatively, you can have different sidebars for them which gives you more flexibility.

Thank you.

Thanks @christopher.amirian ! That works for the main blog page itself but not for the inner blog post, did I do some setup wrong on the sidebars page?

Hi @lwliang1,

At the moment, I could not be able to see what it is wrong in your setup. Following the instruction above should help you.

In this case, please share us your admin credentials in a secure note.

Thanks.

secure note was shared in the first post @nico thanks!

to add: the sidebar that is actually showing up for the inner blog post is the sidebar I have set for the ‘course’ sidebar I created.

Hi,

I checked your blog page and can see that your Main Sidebar is showing up.

Which is correct since you have not selected the post under Blogpost sidebar.

Please review the link below for more information.

Thanks

Thanks @paul.r ! :slight_smile:

Oh I notice that the inner custom post page (learndash course page) that had the sidebar on it before is now not showing the sidebar (it reverted to full width pages).

https://migrationguide.co.uk/courses

Any idea what I can do to get the sidebar on those pages while keeping it on the blog page?

Hi @lwliang1

I’ve modified the code in functions.php to be like that:

// Additional Functions
// =============================================================================
/* LEARNDASH INIZIO */
	/*aggiunge la sidebar solo ai posts di learndash */
add_filter('x_option_x_layout_content', 'add_sidebar_learndash',999);
function add_sidebar_learndash($layout) {  
    if ( 'sfwd-courses' == get_post_type() || 'sfwd-lessons' == get_post_type() || 'sfwd-quiz' == get_post_type() || 'sfwd-topic' == get_post_type() || 'sfwd-certificates' == get_post_type() )  {      
       $layout = "content-sidebar";
   }
  return $layout;
}
	/* sostituisce alla sidebar generica quella specifica che ho creato un sidebars e che ha id ups-sidebar-learndash */
function assign_my_sidebar($sidebar){ 
	if ( x_is_product() ) {
		return 'ups-sidebar-course';
	}
    
	if ( 'sfwd-courses' == get_post_type() || 'sfwd-lessons' == get_post_type() || 'sfwd-quiz' == get_post_type() || 'sfwd-topic' == get_post_type() || 'sfwd-certificates' == get_post_type() )  {      
           return 'ups-sidebar-course';        
    }    
  return $sidebar;
}
add_filter( 'ups_sidebar', 'assign_my_sidebar');

I can see the correct sidebars are now appearing fine on all pages.

Thanks.

1 Like

Thanks! :smile:

You’re welcome! :slight_smile:

1 Like

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