This tutorial will guide you trough to customizing the custom_post_type definition of any WordPress Custom Post Types, but in this article we'll showcase on how to customize eLearn Commerce Specific Post Types.

Fast Way: Use a Plugin Example

Just download and activate one of the plugins below and the customization will be done. This is a simple way for teachers that don't know how to code or don't have an in-house developer yet.

Add the standard excerpt & post_tag fields to eLearn Commerce Courses

1. Know the 5 eLearn Commerce Custom Post Types

  • courses ( plural )
  • ebook ( singular )
  • video ( singular )
  • offer ( singular )
  • wpep_assessment ( singular )

2. Use the Custom Post Type Editor Plugin

This will work only if you want to modify the labels ( how everything is named in the admin ).

I. Download & Install the Plugin

II. ( Optional ) Learn the Post Type Definition Params

III. Go to the Custom Post Type Editor Settings Menu

IV. Scroll Down and find the eLearn Commerce Post Types

V. Click on the Post Type you want to modify. In this example, we'll edit the Courses.

VI. Edit any of the Post Type Definition Labels.

VII. Example use case: name Courses into Execution Plans in the admin.

3. Modify with PHP Code by using filters.

This tutorial requires minimum experience with PHP. You should follow this only if you're comfortable writing code and have done this before, as making a mistake could potentially take your website down.

Minimum Knowledge Required to follow this guide :

We'll hook into the native WordPress filter when a post_type is defined and customize anything from the defaults.

I. Customize the Courses Post Type Base Code
 

function my_website_post_type_courses_definition_args( $args, $post_type ) {
 if( $post_type !== 'courses' )
 return $args;

// Change args here.

return $args;
 }
 add_filter( 'register_post_type_args', 'my_website_post_type_courses_definition_args', 20, 2 );

II. Example: Add the standard excerpt & post_tag fields to eLearn Commerce Courses
 

function my_website_post_type_courses_definition_args( $args, $post_type ) {
 if( $post_type !== 'courses' )
 return $args;

$args['supports'][] = "excerpt";
 $args['taxonomies'][] = "post_tag";

return $args;
 }
 add_filter( 'register_post_type_args', 'my_website_post_type_courses_definition_args', 20, 2 );

III. Example: Add the standard excerpt & post_tag fields to eLearn Commerce EBooks
 

function my_website_post_type_courses_definition_args( $args, $post_type ) {
 if( $post_type !== 'ebook' )
 return $args;

$args['supports'][] = "excerpt";
 $args['taxonomies'][] = "post_tag";

return $args;
 }
 add_filter( 'register_post_type_args', 'my_website_post_type_courses_definition_args', 20, 2 );

IV. Example: Change the capability type of to Page eLearn Commerce Assessments
 

function my_website_post_type_courses_definition_args( $args, $post_type ) {
 if( $post_type !== 'wpep_assessment' )
 return $args;

$args['capability_type'] = "page";
 $args['taxonomies'][] = "post_tag";

return $args;
 }
 add_filter( 'register_post_type_args', 'my_website_post_type_courses_definition_args', 20, 2 );

V. Example: Add the standard excerpt & post_tag fields to all eLearn Commerce Post Types
 

function my_website_post_type_courses_definition_args( $args, $post_type ) {
  if( !in_array( $post_type, [ "courses", "ebook", "video", "offer", "wpep_assessment" ] ) )
 return $args;

$args['supports'][] = "excerpt";
 $args['taxonomies'][] = "post_tag";

return $args;
 }
 add_filter( 'register_post_type_args', 'my_website_post_type_courses_definition_args', 20, 2 );

Did this answer your question?