PHP 语法错误:来自 WordPress Codex 的 WordPress 函数 count_user_posts_by_type
我正在尝试使用 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');
人都可以指出语法错误是什么?
谢谢!
I'm trying to use the following function from 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);
}
But I get the following error:
Parse error: syntax error, unexpected '"', expecting T_STRING in .../wp-content/themes/aa/functions.php on line 106
In my template I tried using it two ways:
$authorcount = count_user_posts_by_type($author->ID, 'videos');
and
$authorcount = count_user_posts_by_type($author->ID, $post_type='videos');
Can anyone point out what the syntax error is?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信第 106 行是这样的
因为有一个明显的语法错误。应该是这样的:
I believe line 106 is this
Because there's an obvious syntax error. It should be like this: