这是我的错误:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'my_scripts_method_2' was given in /home/www/domain.com/wp-includes/plugin.php on line 406
这是给出错误的函数:
add_action('wp_enqueue_scripts', 'my_scripts_method_2');
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "http://domain.com/wp-content/uploads/2013/07/billede.jpg";
}
return $first_img;
}
我只有在启用 GD 星级时才会收到错误消息。此外,问题不太可能是 'my_scripts_method_2 已在使用中。我多次更改名称,仍然给出错误。