{"id":8779,"date":"2022-04-25T05:18:55","date_gmt":"2022-04-24T20:18:55","guid":{"rendered":"https:\/\/www.stuffy.site\/computers\/?p=8779"},"modified":"2022-04-30T09:46:27","modified_gmt":"2022-04-30T00:46:27","slug":"wordpress%e3%81%ae%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%83%bc%e3%81%ae%e8%a4%87%e6%95%b0%e5%8f%96%e5%be%97","status":"publish","type":"post","link":"https:\/\/www.stuffy.site\/computers\/archives\/8779","title":{"rendered":"WordPress\u306e\u30ab\u30c6\u30b4\u30ea\u30fc\u306e\u8907\u6570\u53d6\u5f97"},"content":{"rendered":"\n<p>WordPress\u306e get_the_category() \u306f\u6295\u7a3f\u8a18\u4e8b\u306e\u30ab\u30c6\u30b4\u30ea\u30fc\u3092\u53d6\u5f97\u3059\u308bPHP\u95a2\u6570\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u30eb\u30fc\u30d7\uff08\u304f\u308a\u8fd4\u3057\uff09\u69cb\u6587\u3092\u4f7f\u3063\u3066\u3001\u6295\u7a3f\u8a18\u4e8b\u30ab\u30c6\u30b4\u30ea\u30fc\u3092\u8907\u6570\u8868\u793a\u3059\u308b\u30b3\u30fc\u30c9\u3092\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.stuffy.site\/computers\/2021\/04\/21\/database-connection-error\/\"><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"232\" src=\"https:\/\/www.stuffy.site\/computers\/wp-content\/uploads\/2022\/04\/get_the_category_.png\" alt=\"\" class=\"wp-image-8762\" srcset=\"https:\/\/www.stuffy.site\/computers\/wp-content\/uploads\/2022\/04\/get_the_category_.png 493w, https:\/\/www.stuffy.site\/computers\/wp-content\/uploads\/2022\/04\/get_the_category_-300x141.png 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u306f\u30b5\u30f3\u30d7\u30eb\u30c6\u30fc\u30de\u306e content.php \u306e entry-header \u30bf\u30b0\u306e\u65e5\u4ed8\u8868\u793a\u30b3\u30fc\u30c9\u306e\u6b21\u306b\u633f\u5165\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n<pre><span style=\"color: #0000ff; font-size: 14pt;\">content.php<\/span><br>\n&lt;?php\n$categories = get_the_category(); \/\/ \u60c5\u5831\u53d6\u5f97\n    if ( $categories ) {<br>        foreach ( $categories as $catkey ) {\n            $catId = $catkey-&gt;cat_ID; \/\/ ID\u53d6\u5f97\n            $catName = $catkey-&gt;name; \/\/ \u540d\u79f0\u53d6\u5f97\n            $link = get_category_link($catId); \/\/ \u30ea\u30f3\u30afURL\u53d6\u5f97\n            echo '&lt;span class=\"entry-category\" id=\"' . $catId . '\"&gt;&lt;a href=\"' . $link . '\"&gt;' .$catName . ' &lt;\/a&gt;&lt;\/span&gt;';<br>        }<br>    }<br>?&gt;\n<\/pre>\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u8aac<\/h2>\n\n\n\n<p>foreach \u69cb\u6587\u306f get_the_category() \u95a2\u6570\u3067\u53d6\u5f97\u3057\u305f\u30ab\u30c6\u30b4\u30ea\u30fcID, \u540d\u524d\u3068\u3044\u3063\u305f\u300c\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u300d\u3092\u8981\u7d20\u3068\u3057\u3066\u5404\u914d\u5217\u306b\u683c\u7d0d\u3057\u305f\u308a\u3001\u30bf\u30b0\u751f\u6210\u3059\u308b\u305f\u3081\u306e\u30eb\u30fc\u30d7\uff08\u304f\u308a\u8fd4\u3057\uff09\u51e6\u7406\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n<pre>foreach ( $categories as $catkey ) {<\/pre>\n\n\n<p>$catkey \u306f\u914d\u5217 $categories \u306e\u30ad\u30fc\u3067\u30ab\u30c6\u30b4\u30ea\u30fcID, \u540d\u524d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5225\u306b\u914d\u5217\u306b\u9806\u6b21\u683c\u7d0d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n<pre>    $catId = $catkey-&gt;cat_ID;\n    $catName = $catkey-&gt;name;<\/pre>\n\n\n<p>\u6700\u5f8c\u306b\u30eb\u30fc\u30d7\u672c\u4f53\u306e\u51e6\u7406\u3092 echo \u6587\u3067\u30bf\u30b0\u751f\u6210\u3057\u3066\u30eb\u30fc\u30d7\u3092\u9589\u3058\u307e\u3059\u3002<\/p>\n\n\n<pre>    echo '&lt;span class=\"entry-category\" id=\"' . $catId . '\"&gt;&lt;a href=\"' . $link . '\"&gt;' .$catName . ' &lt;\/a&gt;&lt;\/span&gt;';\n}<\/pre>\n\n\n<h2 class=\"wp-block-heading\">\u30dd\u30a4\u30f3\u30c8<\/h2>\n\n\n\n<p>\u6700\u521d\u3001<a href=\"https:\/\/cotodama.co\/reserved-word\/\">\u4e88\u7d04\u8a9e | WordPress\u3067\u4f7f\u3063\u3066\u306f\u3044\u3051\u306a\u3044\u540d\u524d <\/a> \u3092\u914d\u5217\u30ad\u30fc\u3068\u3057\u3066\u547d\u540d\u3057\u3066\u3057\u307e\u3044\u52d5\u304b\u305a\u306b\u82e6\u5fc3\u3057\u307e\u3057\u305f\u3002\u30c7\u30b6\u30a4\u30f3\u3068\u3057\u3066\u306f span \u30bf\u30b0\u3092\u4f7f\u3063\u3066\u6295\u7a3f\u65e5\u4ed8\u306e\u3068\u306a\u308a\u306b\u6bb5\u843d\u3092\u4f5c\u3089\u305a\u306b\u914d\u7f6e\u3057\u3066\u3044\u308b\u70b9\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u304a\u308f\u308a\u306b<\/h2>\n\n\n\n<p>\u3044\u304b\u304c\u3067\u3057\u305f\u3067\u3057\u3087\u3046\u304b\u3002\u30b3\u30fc\u30c9\u51e6\u7406\u3092\u5b66\u3076\u3068\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306e\u30c7\u30b6\u30a4\u30f3\u601d\u8003\u306e\u7406\u89e3\u304c\u6df1\u307e\u308a\u307e\u3059\u306d\u3002<\/p>\n\n\n\n<p>\u305d\u308c\u3067\u306f\u697d\u3057\u3044PHP\u30e9\u30a4\u30d5\u3092\uff01<\/p>\n\n\n\n<p>\u53c2\u8003URL: <a href=\"https:\/\/newmtube07.com\/wordpress-category\/\">\u3010WordPress\u521d\u5fc3\u8005\u5fc5\u898b\u3011\u8a18\u4e8b\u5185\u306e\u8907\u6570\u306e\u30ab\u30c6\u30b4\u30ea\u30fc\u3092\u3059\u3079\u3066\u53d6\u5f97\u3059\u308b\u65b9\u6cd5<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/bbp.jp\/get-the-name-of-the-wordpress-category-display-create-a-link-to-the-category\/\">WordPress\u306e\u30ab\u30c6\u30b4\u30ea\u30fc\u540d\u3092\u53d6\u5f97\u3057\u3066\u8868\u793a\u3001\u30ab\u30c6\u30b4\u30ea\u30fc\u3078\u306e\u30ea\u30f3\u30af\u3092\u4f5c\u308b\u3002<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/recooord.org\/wordpress-get-the-category\/\">WordPress\u3067\u30ab\u30c6\u30b4\u30ea\u3092\u3059\u3079\u3066\u53d6\u5f97\u3057\u305f\u308a\u3001\u5358\u4f53\u3067\u53d6\u5f97\u3057\u305f\u308a\u3001\u30ea\u30f3\u30af\u4ed8\u304d\u3067\u53d6\u5f97\u3057\u305f\u308a<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u306e get_the_category() \u306f\u6295\u7a3f\u8a18\u4e8b\u306e\u30ab\u30c6\u30b4\u30ea\u30fc\u3092\u53d6\u5f97\u3059\u308bPHP\u95a2\u6570\u3067\u3059\u3002 \u4eca\u56de\u306f\u30eb\u30fc\u30d7\uff08\u304f\u308a\u8fd4\u3057\uff09\u69cb\u6587\u3092\u4f7f\u3063\u3066\u3001\u6295\u7a3f\u8a18\u4e8b\u30ab\u30c6\u30b4\u30ea\u30fc\u3092\u8907\u6570\u8868\u793a\u3059\u308b\u30b3\u30fc\u30c9\u3092\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35,4],"tags":[],"class_list":["post-8779","post","type-post","status-publish","format-standard","hentry","category-php","category-wordpress"],"_links":{"self":[{"href":"https:\/\/www.stuffy.site\/computers\/wp-json\/wp\/v2\/posts\/8779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.stuffy.site\/computers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stuffy.site\/computers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stuffy.site\/computers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stuffy.site\/computers\/wp-json\/wp\/v2\/comments?post=8779"}],"version-history":[{"count":3,"href":"https:\/\/www.stuffy.site\/computers\/wp-json\/wp\/v2\/posts\/8779\/revisions"}],"predecessor-version":[{"id":8826,"href":"https:\/\/www.stuffy.site\/computers\/wp-json\/wp\/v2\/posts\/8779\/revisions\/8826"}],"wp:attachment":[{"href":"https:\/\/www.stuffy.site\/computers\/wp-json\/wp\/v2\/media?parent=8779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stuffy.site\/computers\/wp-json\/wp\/v2\/categories?post=8779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stuffy.site\/computers\/wp-json\/wp\/v2\/tags?post=8779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}