2010.02.28 Sunday
【WordPress】記事ごとのクラス定義に便利な post_class()
記事のループを囲むdivなどの開始タグ内にこれを入れると、下記がClassに定義される
- post
- hentry (hAtom microformat のページ用)
- category-[記事が属するカテゴリのスラッグ]
- tag-[記事に付けられたのタグのスラッグ]
- sticky
第1引数:任意の文字列をclassに定義できる
(複数指定はスペース区切る
★e.g
<?php post_class('xxxxx'); ?>
→「xxxxx」が更にclassに定義できる
第2引数:ループ外で使う場合、記事IDを指定するとその記事に応じたclassが定義される
★e.g
<?php post_class('',$post_id); ?>








