{"id":666,"date":"2017-04-05T20:29:57","date_gmt":"2017-04-05T11:29:57","guid":{"rendered":"http:\/\/www.clarenet.co.jp\/column\/engineer\/?p=666"},"modified":"2017-04-05T20:29:57","modified_gmt":"2017-04-05T11:29:57","slug":"wp%e3%83%91%e3%83%b3%e3%81%8f%e3%81%9a%e3%83%aa%e3%82%b9%e3%83%88","status":"publish","type":"post","link":"https:\/\/4koma-web.com\/coding\/wp%e3%83%91%e3%83%b3%e3%81%8f%e3%81%9a%e3%83%aa%e3%82%b9%e3%83%88\/","title":{"rendered":"WP:\u30d1\u30f3\u304f\u305a\u30ea\u30b9\u30c8"},"content":{"rendered":"<p>\u30ab\u30b9\u30bf\u30e0\u30bf\u30af\u30bd\u30ce\u30df\u30fc\u306e\u30bf\u30fc\u30e0\u60c5\u5831\u3092\u8272\u3005\u306a\u5f62\u3067\u53d6\u5f97\u3001\u51fa\u529b\u3057\u3066\u300c\u30d1\u30f3\u304f\u305a\u30ea\u30b9\u30c8\u300d\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>\u300cget_ancestors\u300d<\/h3>\n<p>\u7956\u5148\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eID\u3092\u914d\u5217\u3067\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"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_ancestors\" target=\"_blank\">\u95a2\u6570\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\/get ancestors<\/a><\/p>\n<pre class=\"lang:default decode:true \" >\/\/\u6295\u7a3f\u306b\u3064\u3044\u3066\u3044\u308b\u30bf\u30fc\u30e0\u306eid\u3092\u53d6\u5f97\n$terms = wp_get_object_terms( $post-&gt;ID, 'my_taxonomy');\n$term_id = $terms[0]-&gt;term_id;\n \n\/\/\u4ee5\u4e0b\u306f\u30bf\u30fc\u30e0\u4e00\u89a7\u30da\u30fc\u30b8\u306e\u5834\u5408\u3068\u540c\u3058\n$$ancestors = get_ancestors( $term_id, 'my_taxonomy' );\n \n$reversed_ancestors = array_reverse($ancestors); \n \nforeach($reversed_ancestors as $ancestor){\n  echo get_term($ancestor)-&gt;name;\n  echo get_term($ancestor)-&gt;slug;\n  echo get_term_link($ancestor);\n}<\/pre>\n<h3>\u300cget_the_terms\u300d<\/h3>\n<p>\u6295\u7a3f\u306b\u5272\u308a\u5f53\u3066\u3089\u308c\u305f\u30bf\u30af\u30bd\u30ce\u30df\u30fc\u306e\u30bf\u30fc\u30e0\uff08\u30ab\u30b9\u30bf\u30e0\u5206\u985e\u306e\u9805\u76ee\uff09\u3092\u53d6\u5f97\u3059\u308b\u3002<\/p>\n<p><a href=\"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\" target=\"_blank\">\u95a2\u6570\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\/get the terms<\/a><\/p>\n<pre class=\"lang:default decode:true \" >&lt;ul class=\"pankuzu\"&gt;\n  &lt;li&gt;&lt;a href=\"&lt;?php echo esc_url( home_url( '\/' ) ); ?&gt;\"&gt;\u30c8\u30c3\u30d7\u30da\u30fc\u30b8&lt;\/a&gt;&lt;\/li&gt;         \n&lt;?php\n  $terms = array_reverse(get_the_terms($post-&gt;ID,'\u30bf\u30af\u30bd\u30ce\u30df\u30fc\u540d'));\n  foreach( $terms as $term ) {\n    echo '&lt;li&gt;&lt;a href=\"\/document\/\u30bf\u30af\u30bd\u30ce\u30df\u30fc\u540d\/'.$term-&gt;slug.'\"&gt;'.$term-&gt;name.'&lt;\/a&gt;&lt;li&gt;' ;\n  }\n?&gt;\n&lt;\/ul&gt;<\/pre>\n<h3>\u300cwalk_category_tree\u300d<\/h3>\n<p>\u30bf\u30fc\u30e0\u306e\u89aa\u5b50\u95a2\u4fc2\u3092\u4fdd\u6301\u3057\u305f\u4e0a\u3067\u8868\u793a\u3059\u308b\u3002<\/p>\n<p>\u5f15\u7528\uff1a<a href=\"http:\/\/pimpmysite.net\/archives\/696\" target=\"_blank\">http:\/\/pimpmysite.net\/archives\/696<\/a><\/p>\n<pre class=\"lang:default decode:true \" >&lt;ul class=\"breadcrumb\"&gt;\n&lt;li&gt;&lt;a href=\"&lt;?php echo esc_url( home_url( '\/' ) ); ?&gt;\"&gt;\u30c8\u30c3\u30d7\u30da\u30fc\u30b8&lt;\/a&gt;&lt;\/li&gt;\n&lt;?php\n  $terms = get_the_terms($post-&gt;ID,'\u30bf\u30af\u30bd\u30ce\u30df\u30fc\u540d');\n  if ( $terms &amp;&amp; ! is_wp_error( $terms ) ) {\n    echo walk_category_tree( $terms, 0 , array(\n    'use_desc_for_title' =&gt; false,\n    'style' =&gt; 'list',\n    ));\n  }\n?&gt;\n&lt;\/ul&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30ab\u30b9\u30bf\u30e0\u30bf\u30af\u30bd\u30ce\u30df\u30fc\u306e\u30bf\u30fc\u30e0\u60c5\u5831\u3092\u8272\u3005\u306a\u5f62\u3067\u53d6\u5f97\u3001\u51fa\u529b\u3057\u3066\u300c\u30d1\u30f3\u304f\u305a\u30ea\u30b9\u30c8\u300d\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002 \u300cget_ancestors\u300d \u7956\u5148\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eID\u3092\u914d\u5217\u3067\u8fd4\u3057\u307e\u3059\u3002 \u95a2\u6570\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\/get ancestors \/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":612,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"","_original_post":"","footnotes":""},"categories":[1],"tags":[],"publishpress_future_action":{"enabled":false,"date":"2026-04-22 02:21:32","action":"change-status","newStatus":"draft","terms":[],"taxonomy":"category"},"_links":{"self":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/posts\/666"}],"collection":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/comments?post=666"}],"version-history":[{"count":0,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/posts\/666\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/media\/612"}],"wp:attachment":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/media?parent=666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/categories?post=666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/tags?post=666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}