Coursepress Pro and Woocommerce product - Variables within shortcodes

There is the customized variable "cp_course_id". How to use it within the shortcodes?
I like to use it instead of the fixed number within the shortcodes:

[course show="description" course_id="5013"]
[course show="enrollment_start, enrollment_end, enrollment_dates" course_id="5013"]
[course_structure course_id="5013"]

will it be possible to use the variable instead of the numbers?
with kind regards

  • Rupok
    • Support Ninja

    Hi Peter

    I hope you had a wonderful day and happy new year.

    For using PHP variable in shortcode, you have to parse the shortcode also in PHP. So you can create a custom page template where you want to use those shortcode and use the following PHP code to achieve what you are trying to do.

    echo do_shortcode( '[course show="description" course_id="'.$cp_course_id.'"]' );
    echo do_shortcode( '[course show="enrollment_start, enrollment_end, enrollment_dates" course_id="'.$cp_course_id.'"]' );
    echo do_shortcode( '[course_structure course_id="'.$cp_course_id.'"]' );

    To know more how to create a custom page template, you can visit this article:

    Please let us know if you have any further confusion. We will be glad to help.

    Have a nice day. Cheers!

  • docmoritz
    • Design Lord, Child of Thor

    Hey Rupok,

    sorry it does not work for me. i dont wont to add a new page template but use the woocommerce product page. and even with added code to functions.php or with trying one of the plugins to inser t "php-code" within text it will not work. So I think the best way is to copy the product and change the course id manually.

    Have a wonderful good day
    regards Peter

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.