Learndash, sidebars not showing on topics

Hello There,

It turns out that you added an invalid PHP code:

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;
}

The correct one should be:

add_filter('x_option_x_layout_content', 'add_sidebar_learndash',999);
function add_sidebar_learndash($layout) {  
    if ( 'product' == get_post_type() || '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;
}

Please have it updated and test your site again.

Hi there

done that, still no sidebar on the lesson level (topics)

Hello There,

I already updated the code and used this:


add_filter('x_option_x_layout_content', 'add_sidebar_learndash',999);
function add_sidebar_learndash($layout) {  
    if ( 'product' == get_post_type() || '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;
}

function assign_learndash_sidebar($sidebar){ 
	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 'sidebar-main';        
	}    
  	return $sidebar;
}
add_filter( 'ups_sidebar', 'assign_learndash_sidebar');
// =============================================================================

The sidebar still not displaying as if there is an error encountered in the sidebar. It is evident in the page source code because the whole sidebar section is not being displayed. Could you please enable the debug mode? You can do this by opening wp-config.php and adding

define('WP_DEBUG', true);

/* That's all, stop editing! Happy blogging. */

When you revisit the page, we should have some error output describing the issue in more detail. And if no error is displayed, please provide us ftp so that we can investigate further.

Thank you.

The debug log writes to here:
http://devel.review/wp-content/debug.log
I’ve just cleared it, and there are no new errors being created.
the wp-config currently is setup like this
define(‘WP_DEBUG’, true);
define(‘WP_DEBUG_LOG’, true);
define(‘WP_DEBUG_DISPLAY’, false);

Hi,

Sorry but we could not access the log file from the browser.

Please provide us your FTP Login in Secure Note so we can check.

Thanks

You really can. It now contains 3 lines. Please check again

Hi @julezedward

I’ve checked the log and these three notices can’t be related to this issue, I’ve also noticed that you have single-topic.php file in your child theme directory, are you sure you got the same behavior with or without this file?

We will need FTP login details in a Secure Note reply in order to investigate this issue in details.

Thanks.

here you go

Hi @julezedward,

There is some kind of cache as the changes won’t take effect immediately even though your cache plugin is already inactive. Perhaps, it’s your host nature.

And the issue with the sidebar and the topic is because the get_sidebar() is unable to call or load the sidebar.php which is weird since all post types in your site is using the same template which works. So instead, I went ahead and manually call the sidebar code through wp-single.php which is now under /wp-content/themes/impulsivity/framework/views/ethos/wp-single.php

<?php

// =============================================================================
// VIEWS/ETHOS/WP-SINGLE.PHP
// -----------------------------------------------------------------------------
// Single post output for Ethos.
// =============================================================================

$fullwidth = get_post_meta( get_the_ID(), '_x_post_layout', true );

get_header();

?>

  <div class="x-container max width main">
    <div class="offset cf">
      <div class="<?php x_main_content_class(); ?>" role="main">
        <?php while ( have_posts() ) : the_post(); ?>
          <?php x_get_view( 'ethos', 'content', get_post_format() ); ?>
          <?php x_get_view( 'global', '_comments-template' ); ?>
        <?php endwhile; ?>

      </div>

      <?php if ( $fullwidth != 'on' ) :?>
        <?php get_sidebar(); ?>
      <?php endif; ?>

      <?php if ( 'sfwd-topic' == get_post_type() ) : ?>

       <aside class="<?php x_sidebar_class(); ?>" role="complementary">
    <?php if ( get_option( 'ups_sidebars' ) != array() ) : ?>
      <?php dynamic_sidebar( apply_filters( 'ups_sidebar', 'sidebar-main' ) ); ?>
    <?php else : ?>
      <?php dynamic_sidebar( 'sidebar-main' ); ?>
    <?php endif; ?>
      </aside>

    <?php endif; ?>

    </div>
  </div>

<?php get_footer(); ?>


Thanks!

Thanks.

Now this page look really bad:
http://devel.review/curriculum/

And actually all of it looks bad now. The sidebar is at the wrong side and contains widgets we don’t need…

Please revert your changes

Hi,

I have removed the file that was added by my colleague.

Thanks

So is there going to be an actual solution provided?

I have a website that works with a different premium theme, or with the stock WP themes, but not with X.

The sidebar is still at the wrong side.

Is it possible to have a refund if this doesn’t work?

Hi,

The sidebar is on the wrong side because the code is somehow changed.

My colleague provided this

The code you added shows sidebar-content

Please change it back to content-sidebar

Thanks

I did not touch the code at all since this ticket was opened. Please provide a solution or refund. This is basic functionality that works with every other theme, except yours.

Thank you

Hey @julezedward,

Upon checking, it looks like the correct sidebar is displaying in both your Single Lessons post and the Curriculum archive page (see secure note).

Now, it worked because of @Rad’s suggestion and in combination with @RueNel code which has been updated by someone. Here’s the code given previously.

When I checked, someone changed return 'sidebar-main'; to return 'ups-sidebar-learndash';. That someone could be one of my colleagues or someone on your side. Not necessarily you.

Now, given that details, I checked Appearance > Sidebars (see Unlimited Sidebars feature of X) and you created a Learndash sidebar.

And, that is what’s used if you use return 'ups-sidebar-learndash';

.

The true reason why you needed those codes in the first place is you set the Global Content Layout to Fullwidth. That shuts off the sidebar for all single posts including custom post types. This is the reason why when you checked other themes, it works because they might not have a similar option.

Just note that if you logout, you won’t see your Learndash sidebar because it needs a logged in user. For that, the https://developer.wordpress.org/reference/functions/is_user_logged_in/ WordPress conditional tag must be used like this:

Thanks.

Thanks @christian_y
You really helped us on the right way. Please let us know how we can have a sidebar not show on individual blog posts while keeping them on the lessons?

Thanks again.

Hi There,

To hide the sidebar on single posts, please add this custom CSS under Theme Options > CSS:

.single-post .x-sidebar {
    display: none;
}
.single-post .x-main {
    width: 100%;
}

Hope that helps and thank you for understanding.

Thank @thai

You’re welcome, @julezedward. Alternatively, you can take what @RueNel’s code suggestion and convert it for posts instead of your Learndash post types like this:

add_filter('x_option_x_layout_content', 'fullwidth_single_post',999);
function fullwidth_single_post($layout) {  
    if ( is_singular( 'post' ) )  {      
       $layout = "full-width";
   }
  return $layout;
}

Or, you can copy the x_get_content_layout function in \framework\functions\frontend and paste it in your child theme’s functions.php override the content layout output of the theme.

Thanks.

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