Enable Topic Comments in Learndash Focus Mode

After upgrading to the Learndash v3 i was facing a big issue with the comments not being visible on any of the topics. 

Even after adding a custom comments template in the theme it would still show the topic has no comments and after debugging for a while i disabled the focus mode and i was able to see all the comments. 

But now i wanted the visual elements of the focus mode.

So i have resolved this for you. What Learndash is doing is its removing the topic comments at the ‘wp’ hook level with the function learndash_remove_comments. 

In my case i did not want Learndash controlling the comments at all so this function worked exactly as i wanted it to.

You can copy the code below and paste it in your functions.php file of the theme. 

add_action( 'wp', 'control_comments' );
function control_comments(){
	remove_filter( 'comments_array', 'learndash_remove_comments', 1, 2 );

	remove_filter('comments_open', 'learndash_comments_open', 10, 2);
}

If the above code shows comments on Course or lesson pages then just disable the comments on them from the admin panel. (In my case they were already disabled for course and lesson post types)

Share on facebook
Facebook
Share on google
Google+
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest

11 Responses

  1. Where do I need to paste this code?

    I pasted it in appearance > theme editor > Theme functions (functions.php) but it doesnt work
    where in the functions.php file should i paste it ?
    After <?php

    1. Fayzan, the code might be conflicting with another function active on the same action. You’ll have to debug that part. Same code is working for me on a clean install.

  2. Thank you very much for this gold mine!
    Helped me to have the comments & still have the Focus mode turned on!

    Thanks a lot!

  3. Thanks! I got the comments back thanks to this suggestion. However, the avatars are now duplicated on those pages and design elements are a somewhat mess. No nesting and reply button on comments doesn’t work. Any ideas where to start looking into this issue?

    1. I am glad the code helped you! Regarding the other issues, it seems like the site has some customization that might be doing all of that. Look for any plugins that were used for the styling of comments or any custom code in place (start with functions.php file).

  4. Thank you for such an easy solution. I have one question. I have thrive comments as a comment platfrom. But on the Focus Mode it is shown as common WordPress comments. How can I enable Thrive comments (or any other comments platfrom) on LearnDahs Focus Mode.

    On the course page there is Thrive comments, so they work ) But not in Focus Mode

    1. Rina, check if Thrive comments has some specific settings about post types and if it needs to be enabled for lessons/topics? If not then probably a custom function needs to be created to replace WordPress comments with Thrive comments.

    1. BBTNG,
      The above function is just removing the LearnDash functions which manipulate the comments functionality. So once the LearnDash functions are removed the next function in priority either in your theme or plugins is doing that. Try looking into functions.php or comments template file in your theme.

Leave a Reply

Your email address will not be published. Required fields are marked *