###目的
プラグイン「Smart custom fields」にて作ったfluits
という名前のカスタムフィールドの中身をディスクリプションとして出力したいです。
Smart custom fields
https://2inc.org/blog/2014/10/09/4426/
###試したこと
functions.phpとheader.phpに次のコードを試したのですが、出力結果でelse
が効いてくれません。
なぜか$fluits
と$description
がどちらも表示されてしまうのです…(>_<)
▼functions.php
php
1function fluits(){ 2$fluits = get_post_meta( get_the_ID () , 'fluits' , true ) ; 3$description = 'テスト'; 4if ( $fluits ) : 5 echo esc_html ( $fluits ) ; 6else : 7 echo $description ; 8endif; 9}
▼header.php
php
1 2<meta name="description" content="<?php fluits() ; ?>" > 3<?php wp_head(); ?> 4</head>
回答1件
あなたの回答
tips
プレビュー