WordPress "Warning: Missing argument 2" 个错误
Wordpress "Warning: Missing argument 2" errors
我遇到了 2 个非常具体的 'missing argument 2' 错误。在 localhost 中一切正常,但是一旦我将所有内容放到网上,它就会返回这些错误:
A) 警告:第 89
行 /home/content/23/9090823/html/extranet/printedcrush/wp-content/themes/facepress/functions.php 中缺少 add_category_to_single() 的参数 2
代码:
add_filter('body_class','add_category_to_single');
(line 89) function add_category_to_single($classes, $class) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
$classes[] = $category->category_nicename;
}
}
return $classes;
}
B) 警告:第 100
行 /home/content/23/9090823/html/extranet/printedcrush/wp-content/themes/facepress/functions.php 中的 my_class_names() 缺少参数 2
代码:
add_filter('body_class','my_class_names');
(line 100) function my_class_names($classes, $class) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
$classes[] = $category->category_nicename;
}
}
if (! ( is_user_logged_in() ) ) {
$classes[] = 'logged-out';
}
return $classes;
}
有人知道我怎样才能修复这些错误吗?
提前致谢。 :)
body_class
过滤器钩子接受一个参数,要修改的类数组,例如:
add_filter( 'body_class', 'so29108478_body_class' );
function so29108478_body_class( $classes ) {
$classes[] = 'my-class';
return $classes;
}
http://codex.wordpress.org/Plugin_API/Filter_Reference/body_class
我遇到了 2 个非常具体的 'missing argument 2' 错误。在 localhost 中一切正常,但是一旦我将所有内容放到网上,它就会返回这些错误:
A) 警告:第 89
行 /home/content/23/9090823/html/extranet/printedcrush/wp-content/themes/facepress/functions.php 中缺少 add_category_to_single() 的参数 2代码:
add_filter('body_class','add_category_to_single');
(line 89) function add_category_to_single($classes, $class) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
$classes[] = $category->category_nicename;
}
}
return $classes;
}
B) 警告:第 100
行 /home/content/23/9090823/html/extranet/printedcrush/wp-content/themes/facepress/functions.php 中的 my_class_names() 缺少参数 2代码:
add_filter('body_class','my_class_names');
(line 100) function my_class_names($classes, $class) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
$classes[] = $category->category_nicename;
}
}
if (! ( is_user_logged_in() ) ) {
$classes[] = 'logged-out';
}
return $classes;
}
有人知道我怎样才能修复这些错误吗? 提前致谢。 :)
body_class
过滤器钩子接受一个参数,要修改的类数组,例如:
add_filter( 'body_class', 'so29108478_body_class' );
function so29108478_body_class( $classes ) {
$classes[] = 'my-class';
return $classes;
}
http://codex.wordpress.org/Plugin_API/Filter_Reference/body_class