• I got this error Warning: Illegal string offset ‘color_class_term_meta’ in C:\xampp\htdocs\CroWrestling\wp-content\themes\newsever\inc\template-tags.php on line 32
    after I tried to create a new category. I haven’t changed anything in the code so I dont know why it suddenly gave me the error. here’s the code:

    if (!function_exists(‘newsever_post_categories’)) :
    function newsever_post_categories($separator = ‘&nbsp’)
    {
    $global_show_categories = newsever_get_option(‘global_show_categories’);
    if ($global_show_categories == ‘no’) {
    return;
    }

    // Hide category and tag text for pages.
    if (‘post’ === get_post_type()) {

    global $post;

    $post_categories = get_the_category($post->ID);
    if ($post_categories) {
    $output = ‘<ul class=”cat-links”>’;
    foreach ($post_categories as $post_category) {
    $t_id = $post_category->term_id;
    $color_id = “category_color_” . $t_id;

    // retrieve the existing value(s) for this meta field. This returns an array
    $term_meta = get_option($color_id);
    $color_class = ($term_meta) ? $term_meta[‘color_class_term_meta’] : ‘category-color-1’;

    $output .= ‘<li class=”meta-category”>
    name)) . ‘”>
    ‘ . esc_html($post_category->name) . ‘

    ‘;
    }
    $output .= ‘‘;
    echo $output;

    }
    }
    }
    endif;

    There is also another error in the categories when I try to edit them in the Color Class. This is the error:

    Warning: Illegal string offset ‘color_class_term_meta’ in C:\xampp\htdocs\CroWrestling\wp-content\themes\newsever\inc\hooks\hook-meta.php on line 203

    and here’s the code:

    if (!function_exists(‘newsever_taxonomy_edit_meta_field’)) :
    // Edit term page
    function newsever_taxonomy_edit_meta_field($term)
    {

    // put the term ID into a variable
    $t_id = $term->term_id;

    // retrieve the existing value(s) for this meta field. This returns an array
    $term_meta = get_option(“category_color_$t_id”);

    ?>
    <tr class=”form-field”>
    <th scope=”row” valign=”top”><label
    for=”term_meta[color_class_term_meta]”><?php _e(‘Color Class’, ‘newsever’); ?></label></th>
    <td>
    <?php
    $cat_color = array(
    ‘category-color-1’ => __(‘Category Color 1’, ‘newsever’),
    ‘category-color-2’ => __(‘Category Color 2’, ‘newsever’),
    ‘category-color-3’ => __(‘Category Color 3’, ‘newsever’),

    );
    ?>
    <select id=”term_meta[color_class_term_meta]” name=”term_meta[color_class_term_meta]”>
    <?php foreach ($cat_color as $key => $value): ?>
    <option value=”<?php echo esc_attr($key); ?>”<?php selected($term_meta[‘color_class_term_meta’], $key); ?> ><?php echo esc_html($value); ?></option>
    <?php endforeach; ?>
    </select>
    <p class=”description”><?php _e(‘Select category color class. You can set appropriate categories color on “Categories” section of the theme customizer.’, ‘newsever’); ?></p>
    </td>
    </tr>
    <?php
    }
    endif;

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Warning: Illegal string offset ‘color_class_term_meta’’ is closed to new replies.