admin管理员组文章数量:1417462
I am trying to include a template file into a loop i made in a shortcode, in a plugin. Everything shows up fine when the template is actually pasted into the loop, but to make things neat I want to separate it into it's own file.
I created a file called hi.php
and it's located in a plugin subfolder called parts
.
Here is the code I place in the loop, but it is not loading the template:
include plugins_url( '/parts/hi.php', __FILE__ );
I am trying to include a template file into a loop i made in a shortcode, in a plugin. Everything shows up fine when the template is actually pasted into the loop, but to make things neat I want to separate it into it's own file.
I created a file called hi.php
and it's located in a plugin subfolder called parts
.
Here is the code I place in the loop, but it is not loading the template:
include plugins_url( '/parts/hi.php', __FILE__ );
1 Answer
Reset to default 2I do it like this:
// Inclusion of additional php files
define( 'MYPLUG_DIR', plugin_dir_path( __FILE__ ) );
require_once( MYPLUG_DIR . 'hi.php' );
It lets you use that more easily if you have to include several files.
本文标签: phpHow to Include a Loop Template File in a Plugin
版权声明:本文标题:php - How to Include a Loop Template File in a Plugin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745261642a2650381.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论