{"id":27082,"date":"2025-05-31T19:14:49","date_gmt":"2025-05-31T10:14:49","guid":{"rendered":"https:\/\/motoki-design.co.jp\/wordpress\/?p=27082"},"modified":"2025-05-31T19:14:51","modified_gmt":"2025-05-31T10:14:51","slug":"custom-field-editor","status":"publish","type":"post","link":"https:\/\/motoki-design.co.jp\/wordpress\/custom-field-editor\/","title":{"rendered":"WordPress\u2502\u7ba1\u7406\u753b\u9762\u306b\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u4e00\u89a7\uff65\u7de8\u96c6\u6a5f\u80fd\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u30c7\u30fc\u30bf\u3092\u4e00\u89a7\u3059\u308b\u3001\u307e\u305f\u306f\u5165\u529b\u3059\u308b\u969b\u306b\u307e\u3068\u3081\u3066\u3084\u3063\u3066\u3057\u307e\u3044\u305f\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4f8b\u3048\u3070\u6709\u6599\u8a18\u4e8b\u306e\u4fa1\u683c\u306a\u306e\u3067\u3059\u304c\u3001\u7ba1\u7406\u753b\u9762\u306b\u5c02\u7528\u30e1\u30cb\u30e5\u30fc\u3092\u4f5c\u308b\u3068\u6642\u77ed\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-border\"><img decoding=\"async\" width=\"812\" height=\"474\" src=\"https:\/\/motoki-design.co.jp\/wordpress\/wp-content\/uploads\/2025-05-31_19h06_26-812x474.png\" alt=\"\" class=\"wp-image-27086\" srcset=\"https:\/\/motoki-design.co.jp\/wordpress\/wp-content\/uploads\/2025-05-31_19h06_26-812x474.png 812w, https:\/\/motoki-design.co.jp\/wordpress\/wp-content\/uploads\/2025-05-31_19h06_26-382x223.png 382w, https:\/\/motoki-design.co.jp\/wordpress\/wp-content\/uploads\/2025-05-31_19h06_26-768x448.png 768w, https:\/\/motoki-design.co.jp\/wordpress\/wp-content\/uploads\/2025-05-31_19h06_26.png 845w\" sizes=\"(max-width: 812px) 100vw, 812px\" \/><\/figure>\n\n\n\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u305d\u306e\u4f5c\u308a\u65b9\u3092\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-group is-style-big_icon_good\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p>\u3061\u306a\u307f\u306b\u3044\u308d\u3044\u308d\u306a\u6280\u8853\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u3088\u304b\u3063\u305f\u3089\u898b\u3066\u304f\u3060\u3055\u3044\u307e\u305b\u3002<\/p>\n\n\n<div class=\"swell-block-postLink\">\t\t\t<a href=\"https:\/\/codoc.jp\/sites\/motoki\" class=\"c-blogLink -external\" data-style=\"text\" target=\"_blank\" rel=\"noopener noreferrer\">\n\t\t\t\t<!-- <i class=\"c-blogLink__icon icon-link\" role=\"presentation\"><\/i> -->\n\t\t\t\t<span class=\"c-blogLink__icon\">\n\t\t\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"swl-svg-externalLink __svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 48 48\" role=\"img\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M44 2H30c-1.1 0-2 .9-2 2s.9 2 2 2h9.2L24 21.2c-.8.8-.8 2 0 2.8s2 .8 2.8 0L42 8.8V18c0 1.1.9 2 2 2s2-.9 2-2V4c0-1.1-.9-2-2-2z\" \/><path d=\"M41 27c-1.1 0-2 .9-2 2v10c0 1.1-.9 2-2 2H9c-1.1 0-2-.9-2-2V11c0-1.1.9-2 2-2h10c1.1 0 2-.9 2-2s-.9-2-2-2H9c-3.3 0-6 2.7-6 6v28c0 3.3 2.7 6 6 6h28c3.3 0 6-2.7 6-6V29c0-1.1-.9-2-2-2z\" \/><\/svg>\t\t\t\t<\/span>\n\t\t\t\t<span class=\"c-blogLink__text\">WAZA\u306e\u6709\u6599\u6280\u8853\u8a18\u4e8b\u4e00\u89a7<\/span>\n\t\t\t<\/a>\n\t\t<\/div><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">WordPress\u306e\u7ba1\u7406\u753b\u9762\u306b\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u4e00\u89a7\uff65\u7de8\u96c6\u6a5f\u80fd\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5<\/h2>\n\n\n\n<p>\u307e\u305a\u306f\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u7528\u610f\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u4fa1\u683c\uff08price\uff09\u3068\u3044\u3046\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3044\u3064\u3082\u3067\u3042\u308c\u3070ACF\u304bSCF\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u4f5c\u6210\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u4e00\u3064\u3067\u3042\u308c\u3070functions.php\u3067\u66f8\u3044\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u4f5c\u6210<\/h3>\n\n\n\n<p>functions.php\u306b\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u633f\u5165\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"is-style-icon_pen\">\u30a8\u30e9\u30fc\u304c\u6016\u3044\u4eba\u306fCode Snippets\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5165\u308c\u3066\u3001\u305d\u3053\u304b\u3089\u30b3\u30fc\u30c9\u3092\u633f\u5165\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>\/\/ \u6295\u7a3f\u753b\u9762\u306b\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u30a8\u30ea\u30a2\u3092\u8ffd\u52a0\nadd_action(&#39;admin_menu&#39;, function () {\n  add_meta_box(\n    &#39;custom_price_box&#39;,\n    &#39;\u4fa1\u683c&#39;,\n    &#39;render_custom_price_field&#39;,\n    &#39;post&#39;,\n    &#39;side&#39;,\n    &#39;default&#39;\n  );\n});\n\n\/\/ \u5165\u529b\u6b04\u306e\u51fa\u529b\nfunction render_custom_price_field($post)\n{\n  wp_nonce_field(&#39;save_custom_price&#39;, &#39;custom_price_nonce&#39;);\n  $price = get_post_meta($post-&gt;ID, &#39;price&#39;, true);\n  echo &#39;&lt;label for=&quot;price&quot;&gt;\u4fa1\u683c\uff08\u5186\uff09&lt;\/label&gt;&#39;;\n  echo &#39;&lt;input type=&quot;number&quot; id=&quot;price&quot; name=&quot;price&quot; value=&quot;&#39; . esc_attr($price) . &#39;&quot; style=&quot;width:100%;&quot; \/&gt;&#39;;\n}\n\n\/\/ \u4fdd\u5b58\u51e6\u7406\nadd_action(&#39;save_post&#39;, function ($post_id) {\n  if (!isset($_POST[&#39;custom_price_nonce&#39;]) || !wp_verify_nonce($_POST[&#39;custom_price_nonce&#39;], &#39;save_custom_price&#39;)) return;\n  if (defined(&#39;DOING_AUTOSAVE&#39;) && DOING_AUTOSAVE) return;\n  if (isset($_POST[&#39;price&#39;])) {\n    update_post_meta($post_id, &#39;price&#39;, sanitize_text_field($_POST[&#39;price&#39;]));\n  }\n});\n<\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u8868\u793a\u5834\u6240<\/h4>\n\n\n\n<p>\u30b3\u30fc\u30c9\u306b<code>side<\/code>\u3068\u8a2d\u5b9a\u3057\u305f\u5834\u5408\u306f\u30b5\u30a4\u30c9\u30d0\u30fc\u306b\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u8a2d\u7f6e\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-border\"><img decoding=\"async\" width=\"297\" height=\"243\" src=\"https:\/\/motoki-design.co.jp\/wordpress\/wp-content\/uploads\/2025-05-31_19h01_53.png\" alt=\"\" class=\"wp-image-27085\"\/><\/figure>\n\n\n\n<p>\u9006\u306b<code>nomal<\/code>\u3068\u3057\u305f\u5834\u5408\u306f\u7de8\u96c6\u8a18\u4e8b\u4e0b\u306b\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u8a2d\u7f6e\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-border\"><img decoding=\"async\" width=\"664\" height=\"286\" src=\"https:\/\/motoki-design.co.jp\/wordpress\/wp-content\/uploads\/2025-05-31_17h34_01.png\" alt=\"\" class=\"wp-image-27084\" srcset=\"https:\/\/motoki-design.co.jp\/wordpress\/wp-content\/uploads\/2025-05-31_17h34_01.png 664w, https:\/\/motoki-design.co.jp\/wordpress\/wp-content\/uploads\/2025-05-31_17h34_01-382x165.png 382w\" sizes=\"(max-width: 664px) 100vw, 664px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u5c02\u7528\u7ba1\u7406\u753b\u9762\u306e\u4f5c\u6210<\/h3>\n\n\n\n<p>\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092functions.php\u306b\u8a18\u8f09\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n\n\n\n<p class=\"is-style-icon_pen\">\u30a8\u30e9\u30fc\u304c\u6016\u3044\u4eba\u306fCode Snippets\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5165\u308c\u3066\u3001\u305d\u3053\u304b\u3089\u30b3\u30fc\u30c9\u3092\u633f\u5165\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u4e00\u5fdc\u3001\u8a18\u4e8b\u304c\u591a\u3044\u5834\u5408\u3092\u60f3\u5b9a\u3057\u3066\u30ab\u30c6\u30b4\u30ea\u30fc\u3068\u30bf\u30b0\u306e\u7d5e\u308a\u8fbc\u307f\u3082\u3064\u3051\u3066\u304a\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"wp-block-codoc-codoc-block\"><div class=\"codoc-entries\" data-without-body=\"1\" id=\"codoc-entry-gqqFrXyPmQ\" ><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u30c7\u30fc\u30bf\u3092\u4e00\u89a7\u3059\u308b\u3001\u307e\u305f\u306f\u5165\u529b\u3059\u308b\u969b\u306b\u307e\u3068\u3081\u3066\u3084\u3063\u3066\u3057\u307e\u3044\u305f\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002 \u4f8b\u3048\u3070\u6709\u6599\u8a18\u4e8b\u306e\u4fa1\u683c\u306a\u306e\u3067\u3059\u304c\u3001\u7ba1\u7406\u753b\u9762\u306b\u5c02\u7528\u30e1\u30cb\u30e5\u30fc\u3092\u4f5c\u308b\u3068\u6642\u77ed\u306b\u306a\u308a\u307e\u3059\u3002 \u672c\u8a18\u4e8b\u3067\u306f\u305d\u306e\u4f5c\u308a\u65b9\u3092\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3059\u3002 \u3061 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":27089,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pochipp_cv_data":"","swell_btn_cv_data":"","footnotes":""},"categories":[91],"tags":[118],"area":[],"class_list":["post-27082","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress-customize","tag-paid"],"_links":{"self":[{"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/posts\/27082","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/comments?post=27082"}],"version-history":[{"count":1,"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/posts\/27082\/revisions"}],"predecessor-version":[{"id":27090,"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/posts\/27082\/revisions\/27090"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/media\/27089"}],"wp:attachment":[{"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/media?parent=27082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/categories?post=27082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/tags?post=27082"},{"taxonomy":"area","embeddable":true,"href":"https:\/\/motoki-design.co.jp\/wordpress\/wp-json\/wp\/v2\/area?post=27082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}