【发布时间】:2014-05-06 14:26:44
【问题描述】:
我为我的主题创建了一个短代码,它将向页面/帖子添加一个投资组合。因为投资组合的代码相当长且复杂,所以我将它放在一个单独的文件中,并尝试使用 get_template_part 从我的 shortcodes.php 文件中调用它。
这是我目前拥有的代码:
function portfolio_new($atts)
{
ob_start();
get_template_part('/includes/shortcode_helpers/portfolio', 'shortcode');
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
add_shortcode('portfolio_new', 'portfolio_new');
但是,这不会返回任何内容。我的包含投资组合 php 的文件位于 incudes/shortcode_helpers/portfolio_shortcode.php
谁能指出我哪里出错了
【问题讨论】: