我正在使用wordpress构建主题并安装了WooCommerce。在查看商店页面时,有一个不同的标题或者根本没有标题(在任何情况下,它不是我设计的那个,也不是首次访问网址时显示的标题)。页面顶部的错误显示
call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in /Applications/MAMP/htdocs/band/wp-includes/plugin.php on line 213
这是调用堆栈
调用堆栈
# Time Memory Function Location
1 0.0001 232984 {main}( ) ../index.php:0
2 0.0002 235792 require( '/Applications/MAMP/htdocs/band/wp-blog-header.php' ) ../index.php:17
3 0.4528 36798136 wp( ) ../wp-blog-header.php:14
4 0.4528 36798400 WP->main( ) ../functions.php:873
5 0.4566 36808800 WP->query_posts( ) ../class-wp.php:611
6 0.4566 36809288 WP_Query->query( ) ../class-wp.php:540
7 0.4566 36817776 WP_Query->get_posts( ) ../query.php:3836
8 0.4573 36834600 do_action_ref_array( ) ../query.php:2377
9 0.4574 36836056 call_user_func_array:{/Applications/MAMP/htdocs/band/wp-includes/plugin.php:571} ( ) ../plugin.php:571
10 0.4574 36837200 WC_Query->pre_get_posts( ) ../plugin.php:571
11 0.4574 36837792 WC_Query->product_query( ) ../class-wc-query.php:294
12 0.4577 36840584 apply_filters( ) ../class-wc-query.php:438
13 0.4578 36841976 call_user_func_array:{/Applications/MAMP/htdocs/band/wp-includes/plugin.php:213} ( ) ../plugin.php:213
来自plugin.php
do { foreach( (array) current($wp_filter[$tag]) as $the_ ) if ( !is_null($the_['function']) ){ $args[1] = $value; $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); } } while ( next($wp_filter[$tag]) !== false );
我尝试在我的本地机器上进行调试,并在plugin.php的第213行停止时对应于该帧的变量的值,但是可能有人只是通过查看才知道出了什么问题?
更新:
我在functions.php中注释掉了这些代码行,错误就消失了
/*
function products_per_page_category( $count ) {
return $count;
}
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
*/
//add_filter( 'loop_shop_per_page', products_per_page_category( 20 ));
但是它仍然没有使用与我模板的其余部分相同的标题。