Coursepress course preview length

Hey guys,

Hope you're fine today !

Just wanted to know how to increase the length of the course preview displaying on the courses page.

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hi, Mehdi!

    I can help!

    Drop this in your theme’s functions.php file:

    add_filter(‘course_admin_excerpt_length’, ‘increase_excerpt_length’:wink:;

    function increase_excerpt_length($length){
    return 100;

    100 here is the number of words in the Course excerpt, you can change it to whatever you’d like.

    Hope this helps!

  • Michelle Shull
    • DEV MAN’s Apprentice


    Let’s try switching the default WP excerpt length, instead. There’s still another option if this doesn’t work, however. Replace the code I gave you with this:

    function custom_excerpt_length( $length ) {
    return 100;
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

    If this doesn’t work, we can rebuild your course page with shortcodes. Instead of using the default, virtual pages that come with CoursePress, we can use the standard Pages > Add New to build a custom list of courses. Hopefully the above function should work for you, but if it doesn’t, you could use something like this combination to create your courses page:

    [course_title course_id="4" link="yes"]
    [course_summary course_id="4" length=100]
    [course_start course_id="4"]
    [course_dates course_id="4" show_alt_display="yes" alt_display_text="Learn Anytime!"]
    [course_enrollment_dates course_id="4"]
    [course_cost course_id="4"]
    [course_list_image course_id="4"]

    You can combine any/all of the shortcodes available under the shortcodes tab to customize the way your course pages display. This is a pretty time consuming way to adjust a simple excerpt length, but it may be our best option if changing the default WP excerpt length doesn’t work.

    Thanks, Mehdi!

  • Mehdi
    • Flash Drive

    Hi Michelle,

    Unfortunately the codes doesnt work :slight_frown:

    As the shortcode option display a different design and is very time consuming, i’m gonna look for another way. If i find a solution will let you know :slight_smile:

    Thx for your time !

  • c0d3r
    • Design Lord, Child of Thor

    Mehdi, I know this is not related to your problem but it is advice

    I have courses online, keep the description on the main page short so the customer, have to take action, and press to read more, even if he already student I title my lecture like that

    lecture#2 Mapping the net

    then detailed info about the lecture inside, since I started using these steps I start getting a lot of attention

    good luck

    ????????? ??? ?????? :slight_smile:

  • Jude
    • DEV MAN

    Hi there @mehdi

    Just chipping in here with a possible solution. The easiest way to do this without editing CORE files is by using a child theme.

    Once in the child theme simply extract and put my content-course.php file in there and it should work.


    Alternately you may replace the original content-course.php with mine in the above folder (Not recommended) . But that needs to be repeated on updates to the plugin.

    Editing line 50 (shown below) in the file can increase/decrease the excerpt length as needed.

    echo do_shortcode( '[course_summary length="100" class="' . $extended_class . '"]' );

    Hope that helps


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.