2012-01-18 13 views
0

からワードプレスの機能count_user_posts_by_type私はhttp://codex.wordpress.org/Function_Reference/count_user_postsPHP構文エラー:WordPressのコーデックス

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'); 

誰でも構文エラーが何であるかを指摘できますか?

ありがとうございます!

答えて

1

私は明らかに構文エラーがありますのでライン106は、この

$count = $wpdb->get_var(\"SELECT COUNT(*) FROM $wpdb->posts $where\"); 

であると考えています。これは次のようになります:

$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} $where");