admin管理员组文章数量:1327123
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.
本文标签: How to include a page template and template part into my plugin
版权声明:本文标题:How to include a page template and template part into my plugin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742201001a2431957.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论