{"id":983,"date":"2015-02-08T23:42:16","date_gmt":"2015-02-08T14:42:16","guid":{"rendered":"http:\/\/www.sriproot.net\/blog\/?p=983"},"modified":"2015-02-08T23:42:16","modified_gmt":"2015-02-08T14:42:16","slug":"categoryid-to-categoryslug","status":"publish","type":"post","link":"https:\/\/www.sriproot.net\/blog\/categoryid-to-categoryslug-983","title":{"rendered":"\u30ab\u30c6\u30b4\u30eaID\u304b\u3089\u30b9\u30e9\u30c3\u30b0\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>WordPress\u306e\u3088\u304f\u4f7f\u3046\u3084\u3064\u3067\u3001\u3061\u3087\u3063\u3068\u307e\u3068\u3081\u305f\u3044\u3068\u601d\u3063\u3066\u307e\u3059\u3002<br \/>\n\u305d\u306e\u5185\u306e\u4e00\u3064\u3002<\/p>\n<p>\u30ab\u30c6\u30b4\u30eaID\u304b\u3089\u30b9\u30e9\u30c3\u30b0\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3067\u3059\u306d\u3002<\/p>\n<p>\u81ea\u5206\u7528\u306e\u30e1\u30e2\u306a\u306e\u3067\u30bd\u30fc\u30b9\u90e8\u5206\u3092\u30b3\u30d4\u30da\u3057\u3084\u3059\u3044\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u4e00\u5fdc\u8aac\u660e\u4ed8\u304d\u3002<br \/>\n<!--more--><\/p>\n<h2>\u76ee\u6b21<\/h2>\n<ol>\n<li><a href=\"#step1\">\u30ab\u30c6\u30b4\u30eaID\u304b\u3089\u30b9\u30e9\u30c3\u30b0\u3092\u53d6\u5f97<\/a><\/li>\n<li><a href=\"#step2\">\u30ab\u30c6\u30b4\u30ea\u306e\u60c5\u5831GET\u3060\u305c\uff01<\/a><\/li>\n<li><a href=\"#step3\">\u3064\u3044\u3067\u306b\u30ab\u30c6\u30b4\u30ea\u540d\u3082\u53d6\u5f97<\/a><\/li>\n<li><a href=\"#step4\">\u307e\u3068\u3081<\/a><\/li>\n<\/ol>\n<h2 id=\"step1\">\u30ab\u30c6\u30b4\u30eaID\u304b\u3089\u30b9\u30e9\u30c3\u30b0\u3092\u53d6\u5f97<\/h2>\n<p>[php]<br \/>\n$cat = get_category(&#8216;1&#8217;);<br \/>\n$cat_slug = $cat->slug;<br \/>\n[\/php]<br \/>\n1\u884c\u76ee\u3067\u30ab\u30c6\u30b4\u30ea\u60c5\u5831\u3092$cat\u306b\u5165\u308c\u307e\u3059\u3002<br \/>\n\u305d\u306e\u4e2d\u304b\u3089\u30b9\u30e9\u30c3\u30b0\u3092$cat_slug\u3068\u3044\u3046\u5909\u6570\u306b\u5165\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u5fc5\u8981\u306a\u5834\u6240\u3067echo\u3057\u3066\u3042\u3052\u308c\u3070\u3001\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2 id=\"step2\">\u30ab\u30c6\u30b4\u30ea\u306e\u60c5\u5831GET\u3060\u305c\uff01<\/h2>\n<p>\u3061\u3087\u3063\u3068\u9806\u756a\u304c\u524d\u5f8c\u3057\u307e\u3059\u304c\u3001$cat\u306b\u306f\u30ab\u30c6\u30b4\u30ea\u306e\u60c5\u5831\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3069\u3093\u306a\u60c5\u5831\u304c\u5165\u3063\u3066\u3044\u308b\u304b\u306f\u3001var_dump($cat)\u3068\u3059\u308c\u3070\u51fa\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u3053\u306e\u30d6\u30ed\u30b0\u306e\u300cWordPress\u30ab\u30c6\u30b4\u30ea\u300d\u306e\u5834\u5408<br \/>\n[php]<br \/>\nobject(stdClass)#2851 (16) {<br \/>\n  [&#8220;term_id&#8221;]=> &#038;int(28)<br \/>\n  [&#8220;name&#8221;]=> &#038;string(9) &#8220;WordPress&#8221;<br \/>\n  [&#8220;slug&#8221;]=> &#038;string(9) &#8220;wordpress&#8221;<br \/>\n  [&#8220;term_group&#8221;]=> int(0)<br \/>\n  [&#8220;term_taxonomy_id&#8221;]=> int(28)<br \/>\n  [&#8220;taxonomy&#8221;]=> string(8) &#8220;category&#8221;<br \/>\n  [&#8220;description&#8221;]=> &#038;string(0) &#8220;&#8221;<br \/>\n  [&#8220;parent&#8221;]=> &#038;int(0)<br \/>\n  [&#8220;count&#8221;]=> &#038;int(10)<br \/>\n  [&#8220;filter&#8221;]=> string(3) &#8220;raw&#8221;<br \/>\n  [&#8220;cat_ID&#8221;]=> &#038;int(28)<br \/>\n  [&#8220;category_count&#8221;]=> &#038;int(10)<br \/>\n  [&#8220;category_description&#8221;]=> &#038;string(0) &#8220;&#8221;<br \/>\n  [&#8220;cat_name&#8221;]=> &#038;string(9) &#8220;WordPress&#8221;<br \/>\n  [&#8220;category_nicename&#8221;]=> &#038;string(9) &#8220;wordpress&#8221;<br \/>\n  [&#8220;category_parent&#8221;]=> &#038;int(0)<br \/>\n}<br \/>\n[\/php]<br \/>\n\u3053\u3093\u306a\u611f\u3058\u3067\u60c5\u5831\u304c\u53d6\u5f97\u51fa\u6765\u307e\u3057\u305f\u3002<br \/>\n2\u884c\u76ee\u306b\u3042\u308b\u300cterm_id\u300d\u3082\u3057\u304f\u306f12\u884c\u76ee\u306e\u300ccat_ID\u300d\u304b\u3089\u3001\u30ab\u30c6\u30b4\u30eaID\u304c28\u3063\u3066\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u4e2d\u3067\u5fc5\u8981\u306a\u60c5\u5831\u3001\u4eca\u56de\u3067\u3042\u308c\u3070\u30b9\u30e9\u30c3\u30b0\u304c\u6b32\u3057\u304b\u3063\u305f\u306e\u3067\u3001slug\u90e8\u5206\u3092\u6307\u5b9a\u3057\u305f\u308f\u3051\u3067\u3059\u306d\u3002<\/p>\n<h2 id=\"step3\">\u3064\u3044\u3067\u306b\u30ab\u30c6\u30b4\u30ea\u540d\u3082\u53d6\u5f97<\/h2>\n<p>\u3060\u3044\u305f\u3044\u30b9\u30e9\u30c3\u30b0\u3068\u308b\u3068\u304d\u306f\u3001\u30ab\u30c6\u30b4\u30ea\u540d\u3082\u4e00\u7dd2\u306b\u4f7f\u3063\u305f\u308a\u3059\u308b\u306e\u3067\u3001\u3064\u3044\u3067\u306b\u30ab\u30c6\u30b4\u30ea\u540d\u3082\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>\u30ab\u30c6\u30b4\u30ea\u540d\u306f\u4e0a\u306e\u30ab\u30c6\u30b4\u30ea\u306e\u60c5\u5831\u306e\u4e2d\u306e3\u884c\u76ee\u300cname\u300d\u3082\u3057\u304f\u306f15\u884c\u76ee\u300ccat_name\u300d\u3092\u4f7f\u3063\u3066<br \/>\n[php]<br \/>\n$cat_name = $cat->name;<br \/>\n[\/php]<br \/>\n\u307b\u3089\u3001\u7c21\u5358\u3067\u3059\u306d\u3002<\/p>\n<p>\u30b9\u30e9\u30c3\u30b0\u3068\u30ab\u30c6\u30b4\u30ea\u540d\u3092\u53d6\u308b\u306a\u3089<br \/>\n[php]<br \/>\n$cat = get_category(&#8216;1&#8217;);<br \/>\n$cat_slug = $cat->slug;<br \/>\n$cat_name = $cat->name;<br \/>\n[\/php]<br \/>\n\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2 id=\"step4\">\u307e\u3068\u3081<\/h2>\n<p>\u81ea\u5206\u7528\u306e\u30e1\u30e2\u306a\u3093\u3067\u3059\u304c\u3001\u4e00\u5fdc\u3053\u308c\u898b\u305f\u4eba\u306e\u305f\u3081\u306b\u5c11\u3057\u8aac\u660e\u3092\u52a0\u3048\u307e\u3057\u305f\u3002<br \/>\n\u3068\u3059\u308b\u3068\u3001\u81ea\u5206\u7528\u306e\u30e1\u30e2\u306b\u5411\u304b\u306a\u3044\u611f\u3058\u3082\u3057\u306a\u304f\u3082\u306a\u3044\u304b\u306a\u2026\u3002<\/p>\n<p>\u3053\u3046\u3044\u3046\u3061\u3087\u3063\u3068\u3057\u305f\u4e00\u884c\u4e8c\u884c\u306e\u3088\u304f\u3064\u304b\u3046\u306e\u3092\u307e\u3068\u3081\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u305d\u3044\u304e\uff5e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u306e\u3088\u304f\u4f7f\u3046\u3084\u3064\u3067\u3001\u3061\u3087\u3063\u3068\u307e\u3068\u3081\u305f\u3044\u3068\u601d\u3063\u3066\u307e\u3059\u3002 \u305d\u306e\u5185\u306e\u4e00&#8230;<\/p>\n","protected":false},"author":2,"featured_media":984,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[28,137],"tags":[138,139,140],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.sriproot.net\/blog\/wp-json\/wp\/v2\/posts\/983"}],"collection":[{"href":"https:\/\/www.sriproot.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sriproot.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sriproot.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sriproot.net\/blog\/wp-json\/wp\/v2\/comments?post=983"}],"version-history":[{"count":0,"href":"https:\/\/www.sriproot.net\/blog\/wp-json\/wp\/v2\/posts\/983\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sriproot.net\/blog\/wp-json\/wp\/v2\/media\/984"}],"wp:attachment":[{"href":"https:\/\/www.sriproot.net\/blog\/wp-json\/wp\/v2\/media?parent=983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sriproot.net\/blog\/wp-json\/wp\/v2\/categories?post=983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sriproot.net\/blog\/wp-json\/wp\/v2\/tags?post=983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}