I’m developing a plugin. This plugin creating a new post type and displaying these posts in a custom template.
For example it’s a event calendar plugin. This plugin creating a new post type ‘event ‘. Users adding new events from wp – admin, like normal blog posts. And users creating a new page with ‘Event Calendar ‘ page template.
But for enabling Event Calendar page template, users have to copy eventcalendar.php from plugin’s dir to their template’s dir.
Last step (copying file) is really hard for some users. Is it possible to call custom page template from plugin dir?
I second Tom’s answer, however in the interest of answering your question, have a look at this question using the
template_include
filter.Probably, but I would advise against this as you would have to make a template that worked with every single theme out there which is not possible. Many people will have broken templates no matter what you do.
Instead try adding a shortcode as a backup for those users who can’t do that additional step.