回答編集履歴
1
$post について追記
test
CHANGED
@@ -1 +1,21 @@
|
|
1
1
|
[get_the_terms](https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/get_the_terms) の第2引数に渡すのは、タクソノミーの名前([register_taxonomy](https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/register_taxonomy) の第1引数で指定したもの)です。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
追記
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
`$post->ID` で投稿IDを参照するのであれば、`global` キーワードを使用する必要があります。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
```php
|
16
|
+
|
17
|
+
global $post;
|
18
|
+
|
19
|
+
$terms = get_the_terms($post->ID, 'blog_category');
|
20
|
+
|
21
|
+
```
|