Tesseract Theme Sidebar Compatibility

Using LifterLMS Labs: Super Sidebars

# Top

As of March 2017, the recommend method for sidebar compatibility is to use LifterLMS Labs: Super Sidebars, a free add-on that allows you to add sidebar compatibility to just about any theme in a matter of seconds without having to write any code. See the full tutorial here.

Manually Adding Sidebar Support

# Top

When using the Tesseract theme, sidebars will work as long as you have sidebars displaying in the Tesseract Layout options under the Customizer. If you select a full-width layout, you’ll want to add the following snippet to your functions.php file. This will ensure that LifterLMS Course and Lesson sidebars display regardless of the site-wide layout options defined by the Tesseract theme.

As is, this adds right-side sidebars to courses and lessons. If you comment out line 16 and uncomment line 15, left-side sidebars will be enabled. You could also pass “fullwidth”, as in line 20, this would make the posts fullwidth.

<?php // Don't copy this line!
/**
* Add layout options for LifterLMS courses, lessons, and quizzes for the Tesseract theme
*
* @since 2016-07-20
*/
/**
* Add layout options for LifterLMS courses, lessons, and quizzes for the Tesseract theme
* @param string $layout default layout according to customizer options
* @return string
*/
function llms_tesseract_layout( $layout ) {
$post_type = get_post_type();
if ( is_singular() ) {
if ( 'course' === $post_type || 'lesson' === $post_type ) {
// $layout = 'sidebar-left'; // for left-side sidebars
$layout = 'sidebar-right'; // for right-side sidebars
} elseif ( 'llms_quiz' === $post_type ) {
$layout = 'fullwidth';
}
}
return $layout;
}
add_filter( 'theme_mod_tesseract_blog_post_layout', 'llms_tesseract_layout', 10, 1 );
/**
* Declare explicit theme support for LifterLMS course and lesson sidebars
* @return void
*/
function my_llms_theme_support(){
add_theme_support( 'lifterlms-sidebars' );
}
add_action( 'after_setup_theme', 'my_llms_theme_support' );

Last Updated on
Was this article helpful?