WordPress_tag_reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*記事に紐づけられたタグ配列情報を取得*/ | |
$tags = get_the_tags(); | |
/*タグ情報が空かどうかを確認*/ | |
if ( !empty( $tags ) ) { | |
/*タグ情報が設定されている場合は、1つ目のタグ情報を読み取り、 | |
fontawsomeのタグを構成し、出力する */ | |
echo '<div><i class="' . $tags[0]->description . '"></i><div>' . $tags[0]->name . '</div></div>'; | |
}else{ | |
/*タグ情報の設定がない場合は、fa-laptop-code の絵文字を出力*/ | |
echo '<div><i class="fas fa-laptop-code"></i><div>' . $tags[0]->name . '</div></div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment