我正在使用一个类将特征图像添加到分类术语中,遵循上的教程http://en.bainternet.info/wordpress-taxonomies-extra-fields-the-easy-way/
这是我在服务中使用的代码。php(CPT文件)
require_once("Tax-meta-class/Tax-meta-class.php");
/*
* configure taxonomy custom fields
*/
$config = array(
\'id\' => \'demo_meta_box\', // meta box id, unique per meta box
\'title\' => \'Demo Meta Box\', // meta box title
\'pages\' => array(\'packages_type\'), // taxonomy name, accept categories, post_tag and custom taxonomies
\'context\' => \'normal\', // where the meta box appear: normal (default), advanced, side; optional
\'fields\' => array(), // list of meta fields (can be added by field arrays)
\'local_images\' => false, // Use local or hosted images (meta box images for add/remove)
\'use_with_theme\' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
);
$my_meta = new Tax_Meta_Class($config);
//Image field
$my_meta->addImage(\'heading\',array(\'name\'=> \'Heading \'));
$my_meta->addImage(\'image\',array(\'name\'=> \'Image \'));
/*
* Don\'t Forget to Close up the meta box deceleration
*/
//Finish Taxonomy Extra fields Deceleration
$my_meta->Finish();
然后我用这个代码来获取图像
<?php $custom_terms= get_terms(\'packages_type\');
$count=1;
$int=1;
foreach($custom_terms as $term):
$heading = get_tax_meta($term->term_id,\'heading\');
$image = get_tax_meta($term->term_id,\'image\');
?>
<img src="<?php echo $heading[\'url\']; ?>" alt="" class="img-responsive">
<img src="<?php echo $image[\'url\']; ?>" alt="">
在localhost上一切正常,但当我将站点移动到live server时,我无法获取图像并在图像标记下获得警告-
illegal string offset \'url\' .我做错了什么