回答編集履歴
1
コード例追記
test
CHANGED
@@ -33,3 +33,31 @@
|
|
33
33
|
|
34
34
|
|
35
35
|
[テンプレートタグ/get the category - WordPress Codex 日本語版](https://wpdocs.osdn.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/get_the_category)
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
---
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
**追記**
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
get_the_category関数の戻り値はオブジェクトなので、こうかもしれません。
|
48
|
+
|
49
|
+
```PHP
|
50
|
+
|
51
|
+
$categories = get_the_category();
|
52
|
+
|
53
|
+
foreach($categories as $category) :
|
54
|
+
|
55
|
+
if('news-topics' === $category->slug) :
|
56
|
+
|
57
|
+
var_dump($category);
|
58
|
+
|
59
|
+
endif;
|
60
|
+
|
61
|
+
endforeach;
|
62
|
+
|
63
|
+
```
|