How Do I Display Widgets Only On Coursepress Pro Units Page?

I actually don’t know how best to put this, but I will give examples of what I mean and state what I want to do.

What I want to do is to display some widgets only on CoursePress Units page.

An example: BuddyPress has “Template Page Types” like BuddyPress Friends, BuddyPress Activity, etc. If I want to display certain widgets on the BuddyPress Activity, I will simply create an override using Rockettheme override feature and assign it only to that BuddYpress Activity page.

But I can’t find anything that has to do with CoursePress pro. I can’t find the units pages.

Any suggestions please?

  • Rupok

    Hi Edwin

    I hope you had a wonderful day.

    The theme can be found in this folder: "wp-content/plugins/coursepress/themes/coursepress/". Simply copy paste that into the theme folder and make changes to it there.

    For making changes in units section, you should edit the "archive-unit.php". For adding a new widget area, you should paste the following code block in functions.php file inside this theme:

    <?php
    /**
     * Register our sidebars and widgetized areas.
     *
     */
    function units_widgets_init() {
    
    	register_sidebar( array(
    		'name'          => 'Unit Section Right Sidebar',
    		'id'            => 'unit_right_1',
    		'before_widget' => '<div>',
    		'after_widget'  => '</div>',
    		'before_title'  => '<h2 class="rounded">',
    		'after_title'   => '</h2>',
    	) );
    
    }
    add_action( 'widgets_init', 'units_widgets_init' );
    ?>

    For showing it in units section, you can paste the following code block where you want to show your widgets:

    <?php if ( is_active_sidebar( 'unit_right_1' ) ) : ?>
    	<div id="primary-sidebar" class="primary-sidebar widget-area" role="complementary">
    		<?php dynamic_sidebar( 'unit_right_1' ); ?>
    	</div><!-- #primary-sidebar -->
    <?php endif; ?>

    Please keep in mind, for showing the widgets properly, you have to adjust the CSS according to your requirements. And you can replace "unit_right_1" with your desired ID.

    Have a nice day. Cheers!
    Rupok

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.