回答編集履歴
1
追記
test
CHANGED
@@ -29,3 +29,83 @@
|
|
29
29
|
```
|
30
30
|
|
31
31
|
このようにすれば出力できると思います。
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
**追記**
|
38
|
+
|
39
|
+
```
|
40
|
+
|
41
|
+
<?php
|
42
|
+
|
43
|
+
$post_id = get_the_ID();
|
44
|
+
|
45
|
+
if( is_singular( 'post' ) ) { //個別投稿ページ
|
46
|
+
|
47
|
+
if ( $meta_key = get_post_meta( $post_id, 'meta_key', true ) ) {
|
48
|
+
|
49
|
+
echo '<meta name="keywords" content="'.$meta_key.'">'."\n";
|
50
|
+
|
51
|
+
} else {
|
52
|
+
|
53
|
+
echo '<meta name="keywords" content="あ,い,う,え,お">'."\n";
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
if( is_page() ) { //固定ページ
|
60
|
+
|
61
|
+
if ( $meta_key = get_post_meta( $post_id, 'meta_key', true ) ) {
|
62
|
+
|
63
|
+
echo '<meta name="keywords" content="'.$meta_key.'">'."\n";
|
64
|
+
|
65
|
+
} else {
|
66
|
+
|
67
|
+
echo '<meta name="keywords" content="あ,い,う,え,お">'."\n";
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
if( is_singular( 'custom_post_type' ) ) { //カスタム投稿ページ
|
74
|
+
|
75
|
+
if ( $meta_key = get_post_meta( $post_id, 'meta_key', true ) ) {
|
76
|
+
|
77
|
+
echo '<meta name="keywords" content="'.$meta_key.'">'."\n";
|
78
|
+
|
79
|
+
} else {
|
80
|
+
|
81
|
+
echo '<meta name="keywords" content="あ,い,う,え,お">'."\n";
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
if( is_category() ) { // カテゴリーページ
|
88
|
+
|
89
|
+
if ( $meta_Key = get_term_meta( get_queried_object()->term_id )['meta_Key'][0] ) {
|
90
|
+
|
91
|
+
echo '<meta name="keywords" content="'.$meta_Key.'">'."\n";
|
92
|
+
|
93
|
+
} else {
|
94
|
+
|
95
|
+
echo '<meta name="keywords" content="あ,い,う,え,お">'."\n";
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
?>
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
必要に応じて条件を追加してください。
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
条件分岐タグ
|
110
|
+
|
111
|
+
[https://wpdocs.osdn.jp/%E6%9D%A1%E4%BB%B6%E5%88%86%E5%B2%90%E3%82%BF%E3%82%B0](https://wpdocs.osdn.jp/%E6%9D%A1%E4%BB%B6%E5%88%86%E5%B2%90%E3%82%BF%E3%82%B0)
|