• I am trying to add a custom sidebar to the Learnpress courses page. For some reason, it does not appear but it does on other pages. Are there restrictions for the “courses” page? If not, what changes do I need to make/add?

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi

    you need check with learn_press_is_courses() and learn_press_is_course_category()

    Thread Starter goforwow

    (@goforwow)

    Sorry, can you please be more clear. I do not know what this means.

    Please be more specific where I need to check or whom I need to check with.

    Hi

    You can find 2 templates
    plugins\learnpress\templates\content-archive-course.php
    plugins\learnpress\templates\content-single-course.php
    Then add sidebar to this page

    There are no sidebar hooks in the template files that I see… could you add what code needs to be added to either file to change the sidebar?

    <?php
    /**
     * Template for displaying course content within the loop.
     *
     * This template can be overridden by copying it to yourtheme/learnpress/content-single-course.php
     *
     * @author  ThimPress
     * @package LearnPress/Templates
     * @version 3.0.0
     */
    
    /**
     * Prevent loading this file directly
     */
    defined( 'ABSPATH' ) || exit();
    
    if ( post_password_required() ) {
    	echo get_the_password_form();
    
    	return;
    }
    
    /**
     * @deprecated
     */
    do_action( 'learn_press_before_main_content' );
    do_action( 'learn_press_before_single_course' );
    do_action( 'learn_press_before_single_course_summary' );
    
    /**
     * @since 3.0.0
     */
    do_action( 'learn-press/before-main-content' );
    
    do_action( 'learn-press/before-single-course' );
    
    ?>
    <div id="learn-press-course" class="course-summary">
    	<?php
    	/**
    	 * @since 3.0.0
    	 *
    	 * @see learn_press_single_course_summary()
    	 */
    	do_action( 'learn-press/single-course-summary' );
    	?>
    </div>
    <?php
    
    /**
     * @since 3.0.0
     */
    do_action( 'learn-press/after-main-content' );
    
    do_action( 'learn-press/after-single-course' );
    
    /**
     * @deprecated
     */
    do_action( 'learn_press_after_single_course_summary' );
    do_action( 'learn_press_after_single_course' );
    do_action( 'learn_press_after_main_content' );
    

    Hi @sean913 @goforwow
    First, you need add this code to function.php file

    add_action( 'get_siderbar_learnpress', 'get_siderbar_learnpress', 10 );
    if ( ! function_exists( 'get_siderbar_learnpress' ) ) :
    	function get_siderbar_learnpress() {
    	if ( $get_post_type == "lpr_course" || $get_post_type == "lpr_quiz" || $get_post_type == "lp_course" || $get_post_type == "lp_quiz" ||
    	thim_check_is_course() || thim_check_is_course_taxonomy() ) {
    				get_sidebar( 'your sidebar' );
    			} else {
    				get_sidebar();
    			}
    		}
    endif;
    

    then go to 2 templates
    plugins\learnpress\templates\content-archive-course.php
    plugins\learnpress\templates\content-single-course.php add

    
    do_action( 'get_siderbar_learnpress' );
    
    • This reply was modified 4 years, 2 months ago by augustus09.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding a custom sidebar to the LearnPress “Courses” page’ is closed to new replies.