I am using a class to add featured images to the taxonomy terms , followed the tutorial on http://en.bainternet.info/wordpress-taxonomies-extra-fields-the-easy-way/

this is the code i used inside my services.php (file for CPT )


* 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

and then i used this code to get theimages

<?php $custom_terms= get_terms('packages_type');    
              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="">

Every thing works fine on localhost but when i moved the site to live server i am unable to get the images and get the warning under image tag -illegal string offset 'url' . What is it that i am doing wrong

  • Sorry. But feeling helpless as my problem doesn't make any sense. – terminator Jan 11 '15 at 11:16

amritanshu you not add id

$my_meta->addText('text_field_id',array('name'=> 'My Text '));


Print Command JUST add that line

$saved_data = get_tax_meta($term_id,'YOUR-FIELD-ID');

echo $saved_data;

  • i have added the id $my_meta->addImage('heading',array('name'=> 'Heading ')); $my_meta->addImage('image',array('name'=> 'Image ')); – terminator Jan 12 '15 at 5:19
  • @amritanshu do you use Prifix? $saved_data = get_tax_meta($term_id,'PRIFIX-YOUR-FIELD-ID'); – Irfan Jan 12 '15 at 20:14
  • no there is no prifix being used in the tut. plus i am also not using it coz there is just 'heading' being used in $my_meta->addImage('heading',array('name'=> 'Heading ')); so i am also using 'heading' only in $heading = get_tax_meta($term->term_id,'heading'); I think you are confusing it with tutorial for the meta boxes where prefix is being used..Any ways thanks – terminator Jan 13 '15 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.