Edit Template File of coursepress

Hi Guyz,

I hope you are enjoying weekend, I have a quick question -

I want to modify this file -

\wp-content\plugins\coursepress\includes\templates\student-dashboard.php

Then where should I put this file in my theme to change it completely ?

Thanks

  • Sajid
    • DEV MAN’s Sidekick

    Hi @Raitis! Hope you are doing good today :slight_smile:

    If you edit the core file it will get replaced by new file when you will update this plugin in future. Rather I suggest you to remove this shortcode and use your own shortcode to and make changes there.

    Add below code in functions.php file of your child theme.

    add_action('init', 'wpmu_remove_parent_shortcodes');
    function wpmu_remove_parent_shortcodes(){
    	remove_shortcode('courses_student_dashboard');
    	add_shortcode( 'custom_courses_student_dashboard', 'custom_courses_student_dashboard' );
    }

    Now copy this function and paste in functions.php file of your child theme.

    function custom_courses_student_dashboard( $atts ) {
    			ob_start();
    			require( 'student-dashboard.php' );
    			$content = ob_get_clean();
    			return $content;
    		}

    Now move the "student-dashboard.php" file from:
    \wp-content\plugins\coursepress\includes\templates\student-dashboard.php

    To:
    wp-content/themes/your-child-theme

    ...and make changes.

    Now use this below shortcode:
    [custom_courses_student_dashboard]

    By replacing this one:
    [courses_student_dashboard]

    Hope this helps and feel free to let me know if you need further support :slight_smile:

    Cheers, Sajid

  • Raitis
    • Site Builder, Child of Zeus

    Hi @Sajid ,

    I found why it was happening !

    Actually when I copied 'Shortcode' from your reply , it was also copying ' < code > < / code > ' tags , and I pasted same in WYSIWYG editor , so that was the issue . Now it is working fine ,

    Thanks again for your support in this thread !

  • Sajid
    • DEV MAN’s Sidekick

    Hi @Raitis! You are welcome :slight_smile:

    Should repeat same for other template file also which I want to customize ?

    Yes you can do exactly what I mention in my reply to override any shortocde/file (if applicable). But you have to find what shortocode and file is being used.

    If I am of any further assistance, please do not hesitate to ask :slight_smile:

    Cheers, Sajid

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.