1. Home
  2. Docs
  3. Reptro
  4. Customize LernPress Course Tabs

Customize LernPress Course Tabs

The LearnPress plugin has a nice filter hook to add or remove the course tabs. Add the following PHP code on your child theme functions.php file and activate the child theme on your site.

Removing The Tabs

/**
 * Remove Tabs
 */

add_filter( 'learn-press/course-tabs', 'reptro_course_tab_remove' );

function reptro_course_tab_remove( $tabs ){

	unset($tabs['curriculum']);
	unset($tabs['reviews']);
	unset($tabs['overview']);
	unset($tabs['instructor']);

	return $tabs;
}

Add Custom Tab

On newer version of the theme we added an option in the theme option to add custom tabs to the course. Go to the admin area – Theme Options – Course Settings. Scroll to the bottom of the page. Here you can see this option.

Custom Tab Adding Option

Or, if you want to add custom tabs using code, follow the code bellow.

/**
 * Add Custom Tab
 */

add_filter( 'learn-press/course-tabs', 'reptro_course_add_custom_tab' );

function reptro_course_add_custom_tab( $tabs ){

	$tabs['custom_tab'] = array(
		'title'    => esc_html__( 'Custom Tab', 'reptro' ),
		'priority' => 50,
		'callback' => 'reptro_custom_tab_content'
	);

	return $tabs;
}

// Custom Tab content

function reptro_custom_tab_content(){
	?>
		<h3>Paragraphs</h3>
		<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
	<?php
}

Renaming Tabs

/* Rename Course tabs */

add_filter( 'learn-press/course-tabs', 'reptro_course_tab_rename' );
function reptro_course_tab_rename( $tabs ){

	$tabs['overview']['title']   	= esc_html__( 'More Information', 'reptro' );
	$tabs['curriculum']['title']  	= esc_html__( 'Course curriculum', 'reptro' );
	$tabs['instructor']['title']  	= esc_html__( 'Teacher', 'reptro' );
	$tabs['reviews']['title']  	    = esc_html__( 'Comments', 'reptro' );

	return $tabs;
}

Adding Dynamic Tabs

You may need adding dynamic tabs to the course, which content can be changed from the course edit page, and the content will be different for each course. Here I am showing you how can you add a custom meta box to the course and show the meta value in the tab content area.