我正在尝试在functions.php中运行do_shortcode但没有运气
我正在使用 Types 插件http://wp-types.com/来创建自定义帖子类型和自定义字段。
我正在尝试在管理员中添加一个自定义列,以查看所有显示自定义字段缩略图的自定义帖子。
这是我到目前为止得到的,但似乎短代码在functions.php中不起作用
// add a column for custom post type (products)
add_filter('manage_product_posts_columns', 'add_thumbnail_column');
add_action('manage_product_posts_custom_column', 'add_thumbnail_content', 10, 2);
function add_thumbnail_column($defaults)
{
$newSlice = array('thumbnail' => 'Image preview');
$counter = 2;
$array_head = array_slice($defaults,0,$counter);
$array_tail = array_slice($defaults,$counter);
$defaults = array_merge($array_head, $newSlice);
$defaults = array_merge($defaults, $array_tail);
return $defaults;
}
function add_thumbnail_content($column_name, $post_ID)
{
// this one works when putting into post content
echo do_shortcode('[types field="square-picture" id="' . $post_ID . '" size="thumbnail"]' . '[/types]');
}
有人可以帮忙吗?