您好我收到了通知未定义索引:行号257。 请帮忙。 这是第257行的代码。
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
global $postID;
$current++;
$category = get_the_category();
$tag = get_cat_ID( $category[0]->name );
$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
if (isset($tag_extra_fields[$tag])) {
$category_icon_code = $tag_extra_fields[$tag]['category_icon_code'];
$category_icon_color = $tag_extra_fields[$tag]['category_icon_color'];
$your_image_url = $tag_extra_fields[$tag]['your_image_url'];
}
if (empty($category_icon_code) || empty($category_icon_color) || empty($your_image_url)) {
$tag = $category[0]->category_parent;
$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
if (isset($tag_extra_fields[$tag])) {
if (empty($category_icon_code)){
$category_icon_code = $tag_extra_fields[$tag]['category_icon_code'];
}
if (empty($category_icon_color)){
$category_icon_color = $tag_extra_fields[$tag]['category_icon_color'];
}
if (empty($your_image_url)){
$your_image_url = $tag_extra_fields[$tag]['your_image_url'];
}
}
}
?>
我为这些获得了未定义的索引。
$category_icon_code
$category_icon_color
$your_image_url
提前致谢。
答案 0 :(得分:0)
在variables
循环之前将这些while
设置为默认值为空:
$category_icon_code = "";
$category_icon_color = "";
$your_image_url = "";