wp_count_posts

Sponsored Link

まず最初に、WordPressバージョン2.5で利用可能です、このテンプレートタグはwp_postsにおける指定されたpost_typeとpost_statusに会う列のカウントを返します。

Sponsored Link

First available with WordPress Version 2.5, this template tag returns the count of the rows in wp_posts that meet the post_type and post_status designated.

wp_count_postsのテンプレートタグ使用方法

<?php wp_count_posts('type', 'status'); ?>

デフォルトの使い方

デフォルト用法は発行されるポストのカウントを返します。

The default usage returns a count of the posts that are published.

<?php $published_posts=wp_count_posts(); ?>

Count drafts

ポスト草稿のカウントを返してください。

Return the count of post drafts.

<?php $draft_posts=wp_count_posts('post','draft'); ?>

Count pages

発行されたページの数をカウントに返してください。

Return the count the number of published pages

<?php $published_pages=wp_count_posts('page','publish'); ?>

wp_count_postsのパラメーター

type

タイプがpost_typeに堪えるところで数えるwp_postsにおける、列のタイプ。 掲示するデフォルト

(string) Type of row in wp_posts to count where type is equal to post_type. Defaults to post

status

状態がpost_statusと等しいところで数えるwp_postsの列の状態。 発行するデフォルト

(string) Status of row in wp_posts to count where status is equal to post_status. Default to publish

関連テンプレートタグ

the_ID,the_title,the_title_attribute,single_post_title,the_title_rss,the_content,
the_content_rss,the_excerpt,the_excerpt_rss,previous_post_link,next_post_link,
posts_nav_link,the_meta

Sponsored Link