我正在尝试使用http://codex.wordpress.org/Function_Reference/count_user_posts中的以下函数
function count_user_posts_by_type($userid, $post_type='post') {
global $wpdb;
$where = get_posts_by_author_sql($post_type, TRUE, $userid);
$count = $wpdb->get_var( \"SELECT COUNT(*) FROM $wpdb->posts $where\" );
return apply_filters('get_usernumposts', $count, $userid);
}
但我收到以下错误:
Parse error: syntax error, unexpected '"', expecting T_STRING in .../wp-content/themes/aa/functions.php on line 106
在我的模板中,我尝试以两种方式使用它:
$authorcount = count_user_posts_by_type($author->ID, 'videos');
和
$authorcount = count_user_posts_by_type($author->ID, $post_type='videos');
谁能指出语法错误是什么?
谢谢!