-
-
Save anonymous/80f096d4127ae0a88f84ba333363f3ac to your computer and use it in GitHub Desktop.
よく使うコード
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
<?php | |
//記事タイトル | |
the_title_attribute(); | |
?> | |
<?php | |
//WordPressのホームURL 引数は追加する文字列 | |
echo home_url('/'); | |
?> | |
<?php | |
//カスタムフィールド表示(文字など) | |
the_field('work_setsumei'); | |
?> | |
<!-- カスタムフィールド画像表示(画像オブジェクト) --> | |
<?php $image = get_field('photo01'); if( !empty($image) ): ?> | |
<a href="<?php echo $image['url']; ?>"><img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" width="450" /></a> | |
<?php endif; ?> | |
<!-- タグリスト表示 --> | |
<?php echo get_the_tag_list('タグ:','/',''); ?> | |
<?php | |
//カテゴリ情報取得 | |
$cat = get_the_category(); | |
$cat = $cat[0]; | |
echo $cat->cat_ID; //カテゴリID表示 | |
echo $cat->cat_name; //カテゴリ名表示 | |
echo $cat->category_nicename; //カテゴリスラッグ表示 | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment