WordPressで記事の数を取得する → wp_count_posts()
wrote :
WordPressで記事の数を取得するには、wp_count_posts() を使う
公開済みの(ふつうの)投稿数を取得
$count_posts = wp_count_posts();
$posts = $count_posts->publish;
公開済みのカスタム投稿数を取得
$count_posts = wp_count_posts( '投稿タイプのスラッグ名' );
$posts = $count_posts->publish;
公開済みの固定ページ数を取得
$count_posts = wp_count_posts( 'page' );
$posts = $count_posts->publish;
$posts = $count_posts->publish;
$count_posts = wp_count_posts( '投稿タイプのスラッグ名' );
$posts = $count_posts->publish;
$posts = $count_posts->publish;
公開済みの固定ページ数を取得
$count_posts = wp_count_posts( 'page' );
$posts = $count_posts->publish;
$posts = $count_posts->publish;