I am creating my first plugin with a template for the frontend.
My current structure is:
/my_plugin/views/page_templates
I have 2 main issues I am trying to resolve
- Is this the best way to include a template
- How to include external files into template using get_template_part()
The template code:
function mbbp_frontend_page_layout($page_template) {
global $post;
if ( is_page("bookings") ) {
$page_template = MBBP_BOOKING_PLUGIN_DIR_PATH . '/views/page-bookings.php';
}
return $page_template;
}
add_filter("page_template", "mbbp_frontend_page_layout");
And then, within page-bookings.php
I have included:
<?php get_template_part( 'page-templates', 'payment-form' ); ?>
The get_template_part() code is not including anything so I am assuming it is because of the way my template is included in the plugin but as this my first plugin, I do not know how to better handle this.