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
    • Support Ninja

    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!

  • redpupmedia
    • Design Lord, Child of Thor

    Hi.
    Thanks for the fast reply.

    We already have a custom theme set up for the site.

    We need to edit the template files for CoursePress. Like if we need to edit the content on a course description page, or a unit's 'navigation' menu (Units | Notifications | Workbook | Course Details)...
    Where can we safely make changes like these?

    Thanks

  • Rupok
    • Support Ninja

    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!

  • redpupmedia
    • Design Lord, Child of Thor

    Thanks.

    So, there is no method to override the output content via template files? That seems odd for such a powerful plugin. Others (like The Event Calendar or WooCommerce) have this option.

    Making all changes via JS will be cumbersome and will break if a user has it turned off.

    Thanks

  • Nithin
    • Support Wizard

    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

  • redpupmedia
    • Design Lord, Child of Thor

    Hello.

    Still stuck on some items here.

    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

    Can you point us in the correct direction?
    Thanks

  • Nithin
    • Support Wizard

    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

  • redpupmedia
    • Design Lord, Child of Thor

    Thanks Nithin,

    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.

    So we copied our edited version to the default Twenty-Fifteen theme and activated that to test. Again, the changes are not being applied.

    Is there some part of the the process we are missing?

    Thanks

  • Nithin
    • Support Wizard

    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

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.