{"id":972,"date":"2017-02-14T10:09:59","date_gmt":"2017-02-14T01:09:59","guid":{"rendered":"http:\/\/blue-bear.jp\/kb\/?p=972"},"modified":"2017-02-14T10:09:59","modified_gmt":"2017-02-14T01:09:59","slug":"wordpress-%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0%e3%81%8b%e3%82%89%e8%87%aa%e5%8b%95%e3%81%a7%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%83%bc%e8%bf%bd%e5%8a%a0","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/wordpress-%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0%e3%81%8b%e3%82%89%e8%87%aa%e5%8b%95%e3%81%a7%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%83%bc%e8%bf%bd%e5%8a%a0\/","title":{"rendered":"[wordpress] \u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u81ea\u52d5\u3067\u30ab\u30c6\u30b4\u30ea\u30fc\u8ffd\u52a0"},"content":{"rendered":"<h2>\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u81ea\u52d5\u3067\u30ab\u30c6\u30b4\u30ea\u30fc\u8ffd\u52a0<\/h2>\n<p>wp-admin\/includes\/taxonomy.php\u306b\u5b58\u5728\u3059\u308bwp_insert_category\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u81ea\u52d5\u3067\u30ab\u30c6\u30b4\u30ea\u30fc\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b<br \/>\n\u91cd\u8907\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u7279\u306b\u4f55\u3082\u3057\u306a\u3044<br \/>\n\u89aa\u30ab\u30c6\u30b4\u30ea\u30fc\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd<\/p>\n<pre>\r\n\r\nrequire_once('\/path\/to\/wp-load.php');\r\nrequire_once('\/path\/to\/wp-admin\/includes\/taxonomy.php');\r\n\r\nfunction addCategory($catName,$parentsID){\r\n    \r\n    $my_cat = array(\r\n        'cat_name' => $catName, \r\n\t'category_nicename' => $catName, \r\n\t'category_parent' => $parentsID);\r\n        \r\n    $my_cat_id = wp_insert_category( $my_cat );\r\n}\r\n\r\n\/\/\u30ab\u30c6\u30b4\u30ea\u30fcID\u691c\u7d22\r\nfunction getCategoryID($catName){\r\n\r\n    if ($term = get_term_by('name', $catName, 'category')){\r\n        $term_ID = $term->term_id;\r\n        return $term_ID;\r\n    }else{\r\n        return 0;\r\n    }\r\n\r\n$parentsID = getCategoryID(\"Apple\"); \/\/Apple\u3068\u3044\u3046\u30ab\u30c6\u30b4\u30ea\u30fc\u304c\u3042\u308b\u304b\u691c\u7d22\r\n$catID = addCategory(\"iPhone\",$parentsID); \/\/Apple\u3068\u3044\u3046\u30ab\u30c6\u30b4\u30ea\u30fc\u306e\u5b50\u30ab\u30c6\u30b4\u30ea\u30fc\u3068\u3057\u3066iPhone\u30ab\u30c6\u30b4\u30ea\u30fc\u3092\u8ffd\u52a0\r\necho $catID; \/\/iPhone\u306e\u30ab\u30c6\u30b4\u30ea\u30fcID\u51fa\u529b\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u81ea\u52d5\u3067\u30ab\u30c6\u30b4\u30ea\u30fc\u8ffd\u52a0 wp<\/p>\n","protected":false},"author":1,"featured_media":962,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[150],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/972"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=972"}],"version-history":[{"count":1,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/972\/revisions"}],"predecessor-version":[{"id":974,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/972\/revisions\/974"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media\/962"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}