我正在尝试使用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');谁能指出语法错误是什么?
谢谢!
发布于 2012-01-18 13:46:15
我相信106行是这样的
$count = $wpdb->get_var( \"SELECT COUNT(*) FROM $wpdb->posts $where\" );因为有一个明显的语法错误。应该是这样的:
$count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} $where" );https://stackoverflow.com/questions/8905369
复制相似问题