Create a new page in a plugin

I’m writing a plugin that lets people add course information online. ‘Courses’ is a custom post type. I’ve already made the admin menu to add the course information to the database (in the post meta table).

Now I need to bring it out onto the front end. Ideally I’d like to make a new template page (single-courses.php) so I can fully customise the page. I’ve not found anything that fits the bill online yet, is there an easy way of generating this through the plugin?

Thanks

1 Answer
1

I managed to do it, not perfect but it works…

add_action('template_redirect', 'my_template');

function my_template(){
global $post;
if( get_post_type($post->ID) == 'courses'){
include(ABSPATH. 'wp-content/plugins/courses/single-course.php');
}

And the file the include points to is my new template file in the plugin.

Leave a Comment