+has_post_format( ‘quote’ )
-
- 投稿がポストフォーマットの引用を含むかどうか確認をして
- 含む場合
- blockquoteエレメントの存在を確認して、無ければ、全体をblockquoteで囲む
add_filter( 'the_content', 'my_quote_content' );
function my_quote_content( $content ) {
/* Check if we're displaying a 'quote' post. */
if ( has_post_format( 'quote' ) ) {
/* Match any <blockquote> elements. */
preg_match( '/<blockquote.*?>/', $content, $matches );
/* If no <blockquote> elements were found, wrap the entire content in one. */
if ( empty( $matches ) )
$content= "<blockquote>\n{$content}\n</blockquote>";
}
return $content;
}
投稿フォーマットを指定した場合、コンテンツをラップするarticle要素には、post_class()関数によって、format-quoteというクラスが出力されるようになります。
/* Style the quote post wrapper. */
.format-quote {}
/* Style blockquotes within the quote post. */
.format-quote blockquote {}
/* Don't forget cite in case a user makes use of it. */
.format-quote cite {}
http://justintadlock.com/archives/2012/08/27/post-formats-quote(@source)
http://justintadlock.com/archives/2012/08/21/post-formats-chat(relate articles)