1 2 3 | <?php if (is_tax( 'chiiki' )): //イベントレポート地域?> <?php endif ; ?> |
投稿者: doggstar
アーカイブだったら
1 2 3 | <?php if (is_archive()): //アーカイブだったら?> <?php endif ; ?> |
ディスプリクションにコンテンツの文字を指定数だけ入れる ソースを改行させない
1 2 3 | <META name= "description" content=" <?php echo mb_substr( str_replace ( array ( "\r\n" , "\r" , "\n" ), '' , strip_tags ( $post ->post_content)), 0, 120 ); //ソースを改行させない コンテンツの文字を指定数だけ入れる?>"> |
ディスプリクションにカスタムフィールドの文字を指定数だけ入れる ソースを改行させない
1 2 3 | <META name= "description" content=" <?php echo mb_substr( str_replace ( array ( "\r\n" , "\r" , "\n" ), '' , strip_tags (get_post_meta( $post ->ID, "プロフィール" ,true))), 0, 120); //ソースを改行させない カスタムフィールドの文字を指定数だけ入れる?>"> |
ディスプリクションのキーワードにタグ名とターム名を入れる
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <META name= "keywords" content="<?php //ターム名リンク無しで取得 $terms = wp_get_post_terms( $post ->ID, 'genre' ); //分類で設定した名称 $names = array (); echo "" ; //前の文字 foreach ( $terms as $term ) { $names [] = $term ->name; } echo implode( ',' , $names ); //区切り文字を指定 ?><?php $terms = wp_get_post_terms( $post ->ID, 'chiiki2' ); //分類で設定した名称 $names = array (); echo "," ; //前の文字 foreach ( $terms as $term ) { $names [] = $term ->name; } echo implode( ',' , $names ); //区切り文字を指定 ?><?php //タグ名リンク無しで取得 $posttags = get_the_tags(); if ( $posttags ) { foreach ( $posttags as $tag ) { echo $tag ->name . ',' ; } } ?>"> |
タグ名リンク無しで取得
1 2 3 4 5 6 7 8 | <?php //タグ名リンク無しで取得 $posttags = get_the_tags(); if ( $posttags ) { foreach ( $posttags as $tag ) { echo $tag ->name . ',' ; } } ?> |
ターム名リンク無しで取得
1 2 3 4 5 6 7 8 9 | <?php //ターム名リンク無しで取得 $terms = wp_get_post_terms( $post ->ID, 'genre' ); //分類で設定した名称 $names = array (); echo "" ; //前の文字 foreach ( $terms as $term ) { $names [] = $term ->name; } echo implode( ',' , $names ); //区切り文字を指定 ?> |