! 各ページ右上の画像広告経由でコンピュータウィルスがダウンロードされた可能性があります。ウィルスチェックをお願いします。詳しくは http://bono.s201.xrea.com/2008/06/693-virus_by_xrea_ad/ をご覧ください。ご迷惑をおかけしてしまい大変申し訳ありません。
テンプレートタグ/wp count posts
出典: ps*wiki
< テンプレートタグ
WordPress 2.5 で初めて使用できるようになった、このテンプレートタグは post_type と post_status で指定した wp_posts の数を返します。
<?php wp_count_posts('type', 'status'); ?>
デフォルトでは公開された記事の数を返します。
<?php $published_posts=wp_count_posts(); ?>
下書きの数を返します。
<?php $draft_posts=wp_count_posts('post','draft'); ?>
公開されたページの数を返します。
<?php $published_pages=wp_count_posts('page','publish'); ?>
- type
- (文字列) 数えたい wp_posts の型。型の値は post_type と同じです。デフォルトは post です
- status
- (文字列) 数えたい wp_posts のステータス。ステータスの値は post_status と同じです。デフォルトは publish です
変更履歴
- 2.5 : 新規テンプレートタグ
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
原文・最新版: WordPress Codex » Template Tags/wp_count_posts (最新版との差分)
