{"id":283,"date":"2023-12-30T02:47:56","date_gmt":"2023-12-29T17:47:56","guid":{"rendered":"https:\/\/ryoccom.com\/?p=283"},"modified":"2023-12-30T02:53:39","modified_gmt":"2023-12-29T17:53:39","slug":"astro%e3%82%84%e3%82%8c%e3%82%84","status":"publish","type":"post","link":"https:\/\/ryoccom.com\/?p=283","title":{"rendered":"Astro\u3084\u308c\u3084"},"content":{"rendered":"\n<p>\u7d50\u5c40\u6c17\u306b\u306a\u3063\u3066Wordpress\u306e\u65b9\u3044\u3058\u3063\u3061\u3083\u3063\u305f\u30fb\u30fb\u30fb\u30fb<br>\u305d\u3082\u305d\u3082Astro\u3084\u308b\u304d\u3063\u304b\u3051\u304c\u3001\u304a\u5ba2\u69d8\u306e\u30b5\u30a4\u30c8\u9ad8\u901f\u5316\u3068\u30ea\u30cb\u30e5\u30fc\u30a2\u30eb\u306e\u3054\u4f9d\u983c\u3067\u3001\u3067\u304d\u308b\u3060\u3051\u74b0\u5883\u4f3c\u305b\u3088\u3046\u3068\u304a\u3082\u3063\u305f\u3089\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u5fc5\u8981\u3084\u3063\u3066\u3093\u3002<br><br>\u305f\u3060ACF\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u5165\u3063\u3066\u308b\u30b5\u30a4\u30c8\u3084\u3063\u305f\u304b\u3089\u7d20\u76f4\u306bACF\u5165\u308c\u308a\u3083\u3088\u304b\u3063\u305f\u306e\u306b\u3001\u306a\u3093\u306a\u3089API\u8aad\u3093\u3067\u308b\u3060\u3051\u3084\u304b\u3089WP\u5074\u306e\u91cd\u3055\u3068\u304b\u8003\u3048\u306a\u304f\u3066\u3044\u3044\u306e\u306b\u81ea\u4f5c\u3067\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u4f5c\u3063\u305f\u3002<br><br>\u305f\u3060\u79c1\u306e\u500b\u4eba\u30d6\u30ed\u30b0\u3067\u306f\u305d\u3053\u307e\u3067\u7d30\u5206\u5316\u3057\u306a\u304f\u3066\u3082\u30ab\u30c6\u30b4\u30ea\u3068\u30bf\u30b0\u3067\u8cc4\u3048\u3066\u3057\u307e\u3063\u3066\u3002\u3002\u3002<br><br>\u4eca\u65e5\u306e\u6c17\u5206\u3068\u304b\u3067\u3044\u3063\u304b\u3002\u3068\u300c\u3046\u304d\u3046\u304d\u300d\u300c\u308f\u304f\u308f\u304f\u300d\u300c\u304b\u306a\u3057\u307f\u300d\u306e3\u3064\u306e\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u3068\u3001meta\u306edescription\u3068keyword\u7528\u306e\u30c6\u30ad\u30b9\u30c8\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8a2d\u7f6e\u5b8c\u4e86\u3002API\u3067\u3082\u53d6\u308c\u308b\u3088\u3046\u306b\u3057\u305f\u3002<br>\uff08ChatGPT\u69d8\u306e\u304a\u304b\u3052\uff09<br><br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">function add_custom_meta_box() {\n    add_meta_box('custom_meta_box', '\u30aa\u30d7\u30b7\u30e7\u30f3', 'custom_meta_box_callback', 'post');\n}\n\nadd_action('add_meta_boxes', 'add_custom_meta_box');\n\nfunction custom_meta_box_callback($post) {\n    \/\/ \u30ce\u30f3\u30b9\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u4f7f\u3063\u3066\u30d5\u30a9\u30fc\u30e0\u3092\u30bb\u30ad\u30e5\u30a2\u306b\u3059\u308b\n    wp_nonce_field('custom_meta_box_nonce', 'meta_box_nonce');\n\n    \/\/ \u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u306e\u72b6\u614b\u3092\u53d6\u5f97\n    $checked_wakuwaku = get_post_meta($post->ID, 'meta_box_wakuwaku', true) === 'yes' ? 'checked' : '';\n    $checked_ukiuki = get_post_meta($post->ID, 'meta_box_ukiuki', true) === 'yes' ? 'checked' : '';\n    $checked_kanashimi = get_post_meta($post->ID, 'meta_box_kanashimi', true) === 'yes' ? 'checked' : '';\n\n    \/\/ \u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u3092\u8868\u793a\n    echo '&lt;p>&lt;label>&lt;input type=\"checkbox\" name=\"meta_box_wakuwaku\" ' . $checked_wakuwaku . '> \u308f\u304f\u308f\u304f&lt;\/label>&lt;\/p>';\n    echo '&lt;p>&lt;label>&lt;input type=\"checkbox\" name=\"meta_box_ukiuki\" ' . $checked_ukiuki . '> \u3046\u304d\u3046\u304d&lt;\/label>&lt;\/p>';\n    echo '&lt;p>&lt;label>&lt;input type=\"checkbox\" name=\"meta_box_kanashimi\" ' . $checked_kanashimi . '> \u304b\u306a\u3057\u307f&lt;\/label>&lt;\/p>';\n    \n    \/\/ meta_description\u306e\u5024\u3092\u53d6\u5f97\u3057\u3066\u30c6\u30ad\u30b9\u30c8\u30a8\u30ea\u30a2\u3068\u3057\u3066\u8868\u793a\n    $meta_description = get_post_meta($post->ID, 'meta_description', true);\n    echo '&lt;p>&lt;label for=\"meta_description\">\u30e1\u30bf\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3:&lt;\/label>';\n    echo '&lt;textarea id=\"meta_description\" name=\"meta_description\" rows=\"4\" cols=\"50\">' . esc_textarea($meta_description) . '&lt;\/textarea>&lt;\/p>';\n\n    \/\/ meta_keyword\u306e\u5024\u3092\u53d6\u5f97\u3057\u3066\u30c6\u30ad\u30b9\u30c8\u30a8\u30ea\u30a2\u3068\u3057\u3066\u8868\u793a\n    $meta_keyword = get_post_meta($post->ID, 'meta_keyword', true);\n    echo '&lt;p>&lt;label for=\"meta_keyword\">\u30e1\u30bf\u30ad\u30fc\u30ef\u30fc\u30c9:&lt;\/label>';\n    echo '&lt;textarea id=\"meta_keyword\" name=\"meta_keyword\" rows=\"2\" cols=\"50\">' . esc_textarea($meta_keyword) . '&lt;\/textarea>&lt;\/p>';\n}\n\nfunction save_custom_meta_box_data($post_id) {\n    \/\/ \u30ce\u30f3\u30b9\u30c1\u30a7\u30c3\u30af\n    if (!isset($_POST['meta_box_nonce']) || !wp_verify_nonce($_POST['meta_box_nonce'], 'custom_meta_box_nonce')) {\n        return;\n    }\n\n    \/\/ \u81ea\u52d5\u4fdd\u5b58\u30c1\u30a7\u30c3\u30af\n    if (defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE) {\n        return;\n    }\n\n    \/\/ \u6a29\u9650\u30c1\u30a7\u30c3\u30af\n    if (!current_user_can('edit_post', $post_id)) {\n        return;\n    }\n\n    \/\/ \u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u306e\u5024\u3092\u66f4\u65b0\n    $wakuwaku = isset($_POST['meta_box_wakuwaku']) ? 'yes' : 'no';\n    $ukiuki = isset($_POST['meta_box_ukiuki']) ? 'yes' : 'no';\n    $kanashimi = isset($_POST['meta_box_kanashimi']) ? 'yes' : 'no';\n\n    update_post_meta($post_id, 'meta_box_wakuwaku', $wakuwaku);\n    update_post_meta($post_id, 'meta_box_ukiuki', $ukiuki);\n    update_post_meta($post_id, 'meta_box_kanashimi', $kanashimi);\n\n    \/\/ meta_description\u3068meta_keyword\u306e\u5024\u3092\u30b5\u30cb\u30bf\u30a4\u30ba\u3057\u3066\u4fdd\u5b58\n    if (isset($_POST['meta_description'])) {\n        update_post_meta($post_id, 'meta_description', sanitize_textarea_field($_POST['meta_description']));\n    }\n    if (isset($_POST['meta_keyword'])) {\n        update_post_meta($post_id, 'meta_keyword', sanitize_textarea_field($_POST['meta_keyword']));\n    }\n}\n\nadd_action('save_post', 'save_custom_meta_box_data');\n\nfunction get_custom_fields_for_rest($object, $field_name, $request) {\n    \/\/ \u30e1\u30bf\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u5024\u3092\u53d6\u5f97\n    $wakuwaku = get_post_meta($object['id'], 'meta_box_wakuwaku', true);\n    $ukiuki = get_post_meta($object['id'], 'meta_box_ukiuki', true);\n    $kanashimi = get_post_meta($object['id'], 'meta_box_kanashimi', true);\n\n    \/\/ \u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u306e\u5024\u306b\u57fa\u3065\u3044\u3066\u6587\u5b57\u5217\u3092\u8a2d\u5b9a\n    $wakuwaku_value = ($wakuwaku === 'yes') ? '\u308f\u304f\u308f\u304f' : '\u672a\u9078\u629e';\n    $ukiuki_value = ($ukiuki === 'yes') ? '\u3046\u304d\u3046\u304d' : '\u672a\u9078\u629e';\n    $kanashimi_value = ($kanashimi === 'yes') ? '\u304b\u306a\u3057\u307f' : '\u672a\u9078\u629e';\n\n    return array(\n        'wakuwaku'        => $wakuwaku_value,\n        'ukiuki'          => $ukiuki_value,\n        'kanashimi'       => $kanashimi_value,\n        'meta_description' => get_post_meta($object['id'], 'meta_description', true),\n        'meta_keyword'    => get_post_meta($object['id'], 'meta_keyword', true),\n    );\n}\n\n<\/pre>\n\n\n\n<p>\u4e0a\u8a18\u3067\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u3067\u3066\u304d\u305f\u3057\u3001<br>\u672c\u5f53\u3044\u3046\u3068\u7ba1\u7406\u753b\u9762\u5074\u306ecss\u3082\u6642\u9593\u304c\u3067\u304d\u305f\u3089\u3064\u304f\u308a\u305f\u3044\u306a<br><br>\u306f\u3088Astro\u3084\u308c\u3084<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7d50\u5c40\u6c17\u306b\u306a\u3063\u3066Wordpress\u306e\u65b9\u3044\u3058\u3063\u3061\u3083\u3063\u305f\u30fb\u30fb\u30fb\u30fb\u305d\u3082\u305d\u3082Astro\u3084\u308b\u304d\u3063\u304b\u3051\u304c\u3001\u304a\u5ba2\u69d8\u306e\u30b5\u30a4\u30c8\u9ad8\u901f\u5316\u3068\u30ea\u30cb\u30e5\u30fc\u30a2\u30eb\u306e\u3054\u4f9d\u983c\u3067\u3001\u3067\u304d\u308b\u3060\u3051\u74b0\u5883\u4f3c\u305b\u3088\u3046\u3068\u304a\u3082\u3063\u305f\u3089\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u5fc5\u8981\u3084\u3063\u3066\u3093\u3002 \u305f\u3060ACF\u306e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[11,14,12],"class_list":["post-283","post","type-post","status-publish","format-standard","hentry","category-work","tag-astro","tag-14","tag-12"],"_links":{"self":[{"href":"https:\/\/ryoccom.com\/index.php?rest_route=\/wp\/v2\/posts\/283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ryoccom.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ryoccom.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ryoccom.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ryoccom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=283"}],"version-history":[{"count":6,"href":"https:\/\/ryoccom.com\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions"}],"predecessor-version":[{"id":289,"href":"https:\/\/ryoccom.com\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions\/289"}],"wp:attachment":[{"href":"https:\/\/ryoccom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ryoccom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ryoccom.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}