Override template files in CoursePress

Hello.

We want to do some re-themeing of CoursePress for a client. How can the template files be overridden in an update-proof manor?

Thanks

  • Rupok

    Hi redpupmedia

    Hope you had a wonderful day.

    How can the template files be overridden in an update-proof manor?

    Inside "/wp-admin/plugins/coursepress/themes" directory in your server, you will get another "coursepress" directory. Copy that directory in "/wp-admin/themes/" directory. Now if you go to "WordPress Dashboard > Appearance > Themes", there you will see your newly copied theme. This theme won't be updated even if the plugin is updates.

    So you can take reference from that theme and design your own or modify that one. This is an update-proof way.

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

    Have a nice day. Cheers!

  • Rupok

    Hi redpupmedia

    Hope you had a wonderful day.

    Suppose you are using a CoursePress shortcode, or a method which generates a certain thing (e.g. Navigation). Now if you want further modification on output content, then either you have to change them on the fly with JavaScript or you have to modify plugin core files. If you have to modify plugin core files to achieve your desired result, then I'm afraid, there is no way you can make them update-proof. When the plugin will update, it will replace all existing files and your customization will be gone.

    In this way, creating a MU Plugin and using JS to make your desired changes seems to be the easiest way. Please let us know your thoughts on this, so we can guide you better.

    Have a nice day. Cheers!

  • Nithin

    Hi redpupmedia,

    Hope you are doing good today. :slight_smile:

    Since you are already using a custom theme, you can make use of the theme inside "/plugins/coursepress/themes/coursepress" as a reference and create template files according to it.
    For eg: To override a course page, you will have to create an 'archive-course.php' and build according to it, for a unit page it would be single-unit.php. The coursepress theme is an example on overriding template files using a theme.

    I hope this is what you were looking for, other than that I'm afraid there isn't any other method available to override those templates.

    Please let us know if you need any further help. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • Nithin

    Hi redpupmedia,

    Hope you are doing good today. :slight_smile:

    Example: We want to edit /plugins/coursepress/includes/templates/single-course-before-details.php
    But can't find that or equivalent in /plugins/coursepress/themes/coursepress

    If I'm not mistaken, content-course-overview.php must be the file you should be looking in the CoursePress theme. You can find the course-box class, and it's relevant shortcodes mentioned in the content-course-overview.php file.

    I hope this is what you were looking for. Please let us know if you need any further assistance. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • Nithin

    Hi redpupmedia,

    Hope you are doing good today. :slight_smile:

    I thought the same. So we copied content-course-overview.php to our theme folder and any edits are not being applied to the site.

    CoursePress makes use of the template hierarchy , you can find how templates are called. To make changes in your theme, you'll have to create a single post template file. That would be single-course.php file, if you give a closer look to coursepress theme you'll find that the content-course-overview.php is being called inside the single-course.php.

    I happen to point the content-course-overview.php file thinking you were editing the coursepress theme.

    I hope this should clear your doubt, please let us know if you need any further help. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin