各ページ右上の画像広告経由でコンピュータウィルスがダウンロードされた可能性があります。ウィルスチェックをお願いします。詳しくは http://bono.s201.xrea.com/2008/06/693-virus_by_xrea_ad/ をご覧ください。ご迷惑をおかけしてしまい大変申し訳ありません。

テンプレートタグ/wp count posts

出典: ps*wiki

目次

説明

WordPress 2.5 で初めて使用できるようになった、このテンプレートタグは post_typepost_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最新版との差分

MediaWiki
他の言語