Shortcodes to show units on a page

I am using your CoursePress plugin I want to know the shortcode to show units on a page?

  • Ash
    • WordPress Hacker

    Hello atlantis

    This is something can’t be easily done I am afraid. But I had a talk with our second level support team and they want to take a look. We can’t promise, but they will try their best within their limit.

    So, I have sent your issue to our second level support team. Please note that, they deal with more complex issues, so there might be little delay. We appreciate your patience on this.

    Have a nice day!



  • Konstantinos Xenos
    • Rubber Duck Debugger

    Hi atlantis ,

    You can add this code snippet into your functions.php ( preferably the child themes ):

    function( $atts ) {
    if ( class_exists( 'CoursePress_Data_Course' ) ) {
    $content = __( 'Please provide a Course ID.', 'coursepress' );

    $a = shortcode_atts(
    'id' => null,

    if ( null !== $a['id'] && intval( $a['id'] ) ) {
    $units = CoursePress_Data_Course::get_units( $a['id'] );
    $content = '';
    foreach ( $units as $unit ) {
    $content .= $unit->post_title . '<br>';

    return $content;

    And you will have a new shortcode that you can use like: [show_cp_units id=”27″] . You will have to change the id to match the ID of the course you want to show it’s Units.

    Tell me if you need further customization with this.



  • Nithin
    • Support Wizard

    Hi atlantis,

    I could notice that behaviour, and I’m checking this with the developer regarding this. If I’m not wrong, the [course] shortcode should be used inside a WordPress loop, ie in a template, if you are looking to make it work with just [course] shortcode.

    Other than that, you’ll have to specify the course_id, title etc to make it work inside the default WordPress editor, ie for example:

    [course show="title,summary,cost,button" course_id="5"]

    You can check the existing shortcodes, and it’s attributes to use, under CoursePress > Settings > Shotcodes section.

    However, I’ll have to double check this workflow with the developer, will keep you posted once I get further updates asap, have a nice day ahead. :slight_smile:



Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.