admin管理员组文章数量:1320661
All the examples seem to be for including page and post templates in a custom plugin, but that's not what I need.
I am trying to include template partials that will wrap and style the output from a function in my custom wordpress plugin. Here is my example:
$chunk = ['header'=>'Header','gallery'=>'Gallery','intro'=>'Intro','description'=>'Description','events'=>'Events','virtual_tour'=>'Virtual Tour','map'=>'Map', 'walkscore'=>'Walkscore','crea_disclaimer'=>'CREA Disclaimer'];
$tpl_data = array(
'property' => $property,
'permalink' => get_post_permalink( $post->ID ),
'post' => $post
);
switch ($chunk) {
case 'description':
return '<p class="description">' . $tpl_data['property']['common']['PublicRemarks'] . '</p>';
case 'header':
return '
<h1 class="dr-header">' .
$tpl_data['property']['address']['street'] .
'<span class="city">' . $tpl_data['property']['address']['city'] . '</span>' .
'</h1>';
}
Instead of returning $tpl_data values wrapped in markup, I want to pass $tpl_data into a template partial that theme builders can override.
I've tried to use get_template_part like this:
case 'description':
return get_template_part( plugin_dir_path( __FILE__ ) . 'templates/er-listing-detail', $tpl_data);
I have a 'templates' directory in the plugin directory with the correctly named partial in it but it doesn't return anything.
Is this possible to do in a wordpress plugin?
本文标签: How can I call template partials inside my custom plugin
版权声明:本文标题:How can I call template partials inside my custom plugin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742064766a2418767.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论