{"id":4319,"date":"2024-10-29T11:45:34","date_gmt":"2024-10-29T03:45:34","guid":{"rendered":"https:\/\/www.openbyt.com\/?p=4319"},"modified":"2024-10-29T11:45:36","modified_gmt":"2024-10-29T03:45:36","slug":"why-is-rest_api_init-not-working-in-my-custom-wordpress-plugin","status":"publish","type":"post","link":"https:\/\/www.openbyt.com\/ja\/\u30ab\u30b9\u30bf\u30e0wordpress\u30d7\u30e9\u30b0\u30a4\u30f3\u3067rest_api_init\u304c\u52d5\u4f5c\u3057\u306a\u3044\u306e\u306f\u306a","title":{"rendered":"WordPress\u306e\u30ab\u30b9\u30bf\u30e0\u30d7\u30e9\u30b0\u30a4\u30f3\u3067rest_api_init\u304c\u52d5\u4f5c\u3057\u306a\u3044\u306e\u306f\u306a\u305c\u3067\u3059\u304b\uff1f"},"content":{"rendered":"<p>\u306e\u554f\u984c\u306b\u906d\u9047\u3057\u307e\u3057\u305f\u3002 <code>rest_api_init<\/code> WordPress\u306e\u30ab\u30b9\u30bf\u30e0\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u52d5\u4f5c\u3057\u306a\u3044\u3053\u3068\u306f\u3001\u7279\u306b\u3059\u3079\u3066\u304c\u6b63\u3057\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u306b\u898b\u3048\u308b\u3068\u304d\u306b\u3001\u975e\u5e38\u306b\u30a4\u30e9\u30a4\u30e9\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u6b21\u306e\u3088\u3046\u306a\u539f\u56e0\u304c\u8003\u3048\u3089\u308c\u307e\u3059\u3002 <code>rest_api_init<\/code> \u304c\u6a5f\u80fd\u3057\u3066\u3044\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308b\u3053\u3068\u3001\u3088\u304f\u3042\u308b\u843d\u3068\u3057\u7a74\u3092\u8abf\u3079\u3001\u30ab\u30b9\u30bf\u30e0 REST API \u30eb\u30fc\u30c8\u3092\u30b7\u30fc\u30e0\u30ec\u30b9\u306b\u52d5\u4f5c\u3055\u305b\u308b\u305f\u3081\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002\u3053\u308c\u306f\u3001WordPress \u3067\u5805\u7262\u306a\u30ab\u30b9\u30bf\u30e0 API \u3092\u69cb\u7bc9\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u958b\u767a\u8005\u306e\u305f\u3081\u306e\u6280\u8853\u7684\u306a\u30c7\u30a3\u30fc\u30d7\u30c0\u30a4\u30d6\u3067\u3059\u3002<\/p><figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.26.34-A-visually-appealing-and-modern-illustration-explaining-the-troubleshooting-process-for-rest_api_init-in-a-custom-WordPress-plugin.-Show-a-well-orga.webp\" alt=\"\" class=\"wp-image-4322\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.26.34-A-visually-appealing-and-modern-illustration-explaining-the-troubleshooting-process-for-rest_api_init-in-a-custom-WordPress-plugin.-Show-a-well-orga.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.26.34-A-visually-appealing-and-modern-illustration-explaining-the-troubleshooting-process-for-rest_api_init-in-a-custom-WordPress-plugin.-Show-a-well-orga-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.26.34-A-visually-appealing-and-modern-illustration-explaining-the-troubleshooting-process-for-rest_api_init-in-a-custom-WordPress-plugin.-Show-a-well-orga-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.26.34-A-visually-appealing-and-modern-illustration-explaining-the-troubleshooting-process-for-rest_api_init-in-a-custom-WordPress-plugin.-Show-a-well-orga-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.26.34-A-visually-appealing-and-modern-illustration-explaining-the-troubleshooting-process-for-rest_api_init-in-a-custom-WordPress-plugin.-Show-a-well-orga-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.26.34-A-visually-appealing-and-modern-illustration-explaining-the-troubleshooting-process-for-rest_api_init-in-a-custom-WordPress-plugin.-Show-a-well-orga-768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.26.34-A-visually-appealing-and-modern-illustration-explaining-the-troubleshooting-process-for-rest_api_init-in-a-custom-WordPress-plugin.-Show-a-well-orga-12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.26.34-A-visually-appealing-and-modern-illustration-explaining-the-troubleshooting-process-for-rest_api_init-in-a-custom-WordPress-plugin.-Show-a-well-orga-96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><h3 class=\"wp-block-heading\">WordPress\u306b\u304a\u3051\u308brest_api_init\u3068\u305d\u306e\u5f79\u5272\u306e\u7406\u89e3<\/h3><p>\u3092 <code>rest_api_init<\/code> \u30a2\u30af\u30b7\u30e7\u30f3\u30d5\u30c3\u30af\u306f\u3001WordPress REST API \u306b\u30ab\u30b9\u30bf\u30e0\u30eb\u30fc\u30c8\u3084\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002REST API \u30b5\u30fc\u30d0\u30fc\u304c\u521d\u671f\u5316\u3055\u308c\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u3001\u901a\u5e38\u306f\u65b0\u3057\u3044 REST API \u30eb\u30fc\u30c8\u3092\u767b\u9332\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u30ab\u30b9\u30bf\u30e0\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u304c\u671f\u5f85\u901a\u308a\u306b\u52d5\u4f5c\u3057\u306a\u3044\u5834\u5408\u3001\u591a\u304f\u306e\u5834\u5408\u306f\u8a2d\u5b9a\u30df\u30b9\u304b <code>rest_api_init<\/code>.\u30d5\u30c3\u30af\u306e\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3068 WordPress \u306b\u304a\u3051\u308b\u5f79\u5272\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u306f\u3001API \u306e\u62e1\u5f35\u3092\u6210\u529f\u3055\u305b\u308b\u305f\u3081\u306b\u4e0d\u53ef\u6b20\u3067\u3059\u3002<\/p><figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.22.40-A-clear-educational-illustration-showing-the-role-of-the-rest_api_init-action-hook-in-WordPress-focusing-on-adding-custom-routes-and-endpoints-to-.webp\" alt=\"\" class=\"wp-image-4320\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.22.40-A-clear-educational-illustration-showing-the-role-of-the-rest_api_init-action-hook-in-WordPress-focusing-on-adding-custom-routes-and-endpoints-to-.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.22.40-A-clear-educational-illustration-showing-the-role-of-the-rest_api_init-action-hook-in-WordPress-focusing-on-adding-custom-routes-and-endpoints-to--600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.22.40-A-clear-educational-illustration-showing-the-role-of-the-rest_api_init-action-hook-in-WordPress-focusing-on-adding-custom-routes-and-endpoints-to--100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.22.40-A-clear-educational-illustration-showing-the-role-of-the-rest_api_init-action-hook-in-WordPress-focusing-on-adding-custom-routes-and-endpoints-to--300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.22.40-A-clear-educational-illustration-showing-the-role-of-the-rest_api_init-action-hook-in-WordPress-focusing-on-adding-custom-routes-and-endpoints-to--150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.22.40-A-clear-educational-illustration-showing-the-role-of-the-rest_api_init-action-hook-in-WordPress-focusing-on-adding-custom-routes-and-endpoints-to--768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.22.40-A-clear-educational-illustration-showing-the-role-of-the-rest_api_init-action-hook-in-WordPress-focusing-on-adding-custom-routes-and-endpoints-to--12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.22.40-A-clear-educational-illustration-showing-the-role-of-the-rest_api_init-action-hook-in-WordPress-focusing-on-adding-custom-routes-and-endpoints-to--96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><h3 class=\"wp-block-heading\">rest_api_init \u304c\u52d5\u4f5c\u3057\u306a\u3044\u4e00\u822c\u7684\u306a\u7406\u7531<\/h3><p>\u6700\u3082\u4e00\u822c\u7684\u306a\u7406\u7531\u3092\u6319\u3052\u3066\u307f\u307e\u3057\u3087\u3046\u3002 <code>rest_api_init<\/code> WordPress\u306e\u30ab\u30b9\u30bf\u30e0\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u52d5\u4f5c\u3057\u3066\u3044\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u3001\u305d\u308c\u305e\u308c\u306e\u554f\u984c\u306b\u5bfe\u3059\u308b\u5b9f\u8df5\u7684\u306a\u89e3\u6c7a\u7b56\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p><h4 class=\"wp-block-heading\">1.\u30d5\u30c3\u30af\u306e\u914d\u7f6e\u3068\u30bf\u30a4\u30df\u30f3\u30b0\u306e\u554f\u984c<\/h4><p>\u6700\u3082\u4e00\u822c\u7684\u306a\u7406\u7531\u306f <code>rest_api_init<\/code> \u52d5\u304b\u306a\u3044\u306e\u306f\u3001\u30d5\u30c3\u30af\u306e\u4f4d\u7f6e\u304c\u6b63\u3057\u304f\u306a\u3044\u304b\u3089\u3067\u3059\u3002\u305d\u306e <code>rest_api_init<\/code> \u30a2\u30af\u30b7\u30e7\u30f3\u30d5\u30c3\u30af\u306f\u3001WordPress \u304c\u3059\u3079\u3066\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u521d\u671f\u5316\u3057\u305f\u5f8c\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u901a\u5e38\u3001\u30e1\u30a4\u30f3\u30d7\u30e9\u30b0\u30a4\u30f3\u30d5\u30a1\u30a4\u30eb\u304b\u5225\u306e\u521d\u671f\u5316\u95a2\u6570\u306b\u3053\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3001WordPress \u30b3\u30a2\u3068\u4f9d\u5b58\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u5b8c\u5168\u306b\u30ed\u30fc\u30c9\u3055\u308c\u305f\u5f8c\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p><figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.27.55-A-clear-and-modern-illustration-explaining-the-correct-usage-of-the-rest_api_init-action-hook-in-WordPress-plugin-development-focused-on-correct-ho.webp\" alt=\"\" class=\"wp-image-4323\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.27.55-A-clear-and-modern-illustration-explaining-the-correct-usage-of-the-rest_api_init-action-hook-in-WordPress-plugin-development-focused-on-correct-ho.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.27.55-A-clear-and-modern-illustration-explaining-the-correct-usage-of-the-rest_api_init-action-hook-in-WordPress-plugin-development-focused-on-correct-ho-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.27.55-A-clear-and-modern-illustration-explaining-the-correct-usage-of-the-rest_api_init-action-hook-in-WordPress-plugin-development-focused-on-correct-ho-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.27.55-A-clear-and-modern-illustration-explaining-the-correct-usage-of-the-rest_api_init-action-hook-in-WordPress-plugin-development-focused-on-correct-ho-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.27.55-A-clear-and-modern-illustration-explaining-the-correct-usage-of-the-rest_api_init-action-hook-in-WordPress-plugin-development-focused-on-correct-ho-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.27.55-A-clear-and-modern-illustration-explaining-the-correct-usage-of-the-rest_api_init-action-hook-in-WordPress-plugin-development-focused-on-correct-ho-768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.27.55-A-clear-and-modern-illustration-explaining-the-correct-usage-of-the-rest_api_init-action-hook-in-WordPress-plugin-development-focused-on-correct-ho-12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.27.55-A-clear-and-modern-illustration-explaining-the-correct-usage-of-the-rest_api_init-action-hook-in-WordPress-plugin-development-focused-on-correct-ho-96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>\u89e3\u6c7a\u7b56<\/strong> \u3092\u4f7f\u7528\u3057\u3066\u30ab\u30b9\u30bf\u30e0\u30eb\u30fc\u30c8\u3092\u767b\u9332\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002 <code>rest_api_init<\/code> \u6b63\u3057\u3044\u6587\u8108\u3067<\/p><pre class=\"wp-block-code\"><code>add_action('rest_api_init', 'register_custom_api_routes')\uff1b\n\n\u95a2\u6570 register_custom_api_routes() {\n    register_rest_route('myplugin\/v1', '\/content\/', array(\n        'methods' =&gt; 'GET'\u3001\n        'callback' =&gt; 'get_custom_content'\u3001\n        'permission_callback' =&gt; '__return_true', \/\/ \u9069\u5207\u306b\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\n    ));\n}<\/code><\/pre><p><strong>\u8aac\u660e<\/strong><\/p><ol start=\"1\" class=\"wp-block-list\"><li><code>add_action('rest_api_init', 'register_custom_api_routes')\uff1b<\/code> - \u3053\u306e\u884c\u306f <code>rest_api_init<\/code> \u3092\u4f7f\u7528\u3057\u3066\u3001REST API \u304c\u521d\u671f\u5316\u3055\u308c\u305f\u3089\u30ab\u30b9\u30bf\u30e0\u30eb\u30fc\u30c8\u3092\u767b\u9332\u3057\u307e\u3059\u3002<\/li>\n\n<li><code>register_rest_route('myplugin\/v1', '\/content\/', ...)<\/code> - \u3053\u306e\u95a2\u6570\u306f\u3001\u65b0\u3057\u3044 REST API \u30eb\u30fc\u30c8\u3092\u767b\u9332\u3057\u307e\u3059\u3002\u540d\u524d\u7a7a\u9593 (<code>'myplugin\/v1'<\/code>)\u306f\u4ed6\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3068\u306e\u885d\u7a81\u3092\u907f\u3051\u308b\u305f\u3081\u306b\u30eb\u30fc\u30c8\u3092\u4e00\u610f\u306b\u8b58\u5225\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/li>\n\n<li><code>'permission_callback' =&gt; '__return_true'<\/code> - \u3053\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306f\u3001\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3059\u3079\u3066\u306e\u4eba\u306b\u8a31\u53ef\u3092\u4e0e\u3048\u307e\u3059\u3002\u5b9f\u969b\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u78ba\u4fdd\u3059\u308b\u305f\u3081\u306b\u3001\u3053\u308c\u3092\u9069\u5207\u306a\u30e6\u30fc\u30b6\u30fc\u80fd\u529b\u30c1\u30a7\u30c3\u30af\u306b\u7f6e\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/li><\/ol><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/7b189a88-66a0-426a-a492-ef33c9639f77.webp\" alt=\"\" class=\"wp-image-4324\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/7b189a88-66a0-426a-a492-ef33c9639f77.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/7b189a88-66a0-426a-a492-ef33c9639f77-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/7b189a88-66a0-426a-a492-ef33c9639f77-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/7b189a88-66a0-426a-a492-ef33c9639f77-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/7b189a88-66a0-426a-a492-ef33c9639f77-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/7b189a88-66a0-426a-a492-ef33c9639f77-768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/7b189a88-66a0-426a-a492-ef33c9639f77-12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/7b189a88-66a0-426a-a492-ef33c9639f77-96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p>\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001\u30e1\u30a4\u30f3\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u30d5\u30a1\u30a4\u30eb\u5185\u304b\u3001\u3059\u3079\u3066\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u30ed\u30fc\u30c9\u3055\u308c\u305f\u5f8c\u306b\u5b9f\u884c\u3055\u308c\u308b\u95a2\u6570\u5185\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002 <code>\u30d7\u30e9\u30b0\u30a4\u30f3\u30ed\u30fc\u30c9<\/code>.\u30d5\u30c3\u30af\u306e\u4f4d\u7f6e\u304c\u6b63\u3057\u304f\u306a\u3044\u5834\u5408\u3001\u30eb\u30fc\u30c8\u304c\u6b63\u3057\u304f\u767b\u9332\u3055\u308c\u306a\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p><h4 class=\"wp-block-heading\">2.\u7af6\u5408\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3084\u30c6\u30fc\u30de<\/h4><p>\u3082\u3046\u4e00\u3064\u306e\u4e00\u822c\u7684\u306a\u7406\u7531\u306f <code>rest_api_init<\/code> \u304c\u52d5\u4f5c\u3057\u306a\u3044\u5834\u5408\u3001\u30eb\u30fc\u30c8\u3092\u767b\u9332\u3059\u308b\u4ed6\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3084\u30c6\u30fc\u30de\u3068\u7af6\u5408\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u30022\u3064\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u540c\u3058\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u767b\u9332\u3057\u3088\u3046\u3068\u3057\u305f\u308a\u3001\u30c6\u30fc\u30de\u304c\u540c\u3058\u3088\u3046\u306a\u30eb\u30fc\u30c8\u3092\u6301\u3063\u3066\u3044\u305f\u308a\u3059\u308b\u3068\u3001\u7af6\u5408\u304c\u767a\u751f\u3057\u3001\u30ab\u30b9\u30bf\u30e0\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u304c\u6b63\u3057\u304f\u6a5f\u80fd\u3057\u306a\u304f\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.23-An-educational-illustration-explaining-the-importance-of-unique-namespace-prefixes-in-WordPress-REST-API-routes-to-avoid-conflicts.-Show-a-developers.webp\" alt=\"\" class=\"wp-image-4326\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.23-An-educational-illustration-explaining-the-importance-of-unique-namespace-prefixes-in-WordPress-REST-API-routes-to-avoid-conflicts.-Show-a-developers.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.23-An-educational-illustration-explaining-the-importance-of-unique-namespace-prefixes-in-WordPress-REST-API-routes-to-avoid-conflicts.-Show-a-developers-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.23-An-educational-illustration-explaining-the-importance-of-unique-namespace-prefixes-in-WordPress-REST-API-routes-to-avoid-conflicts.-Show-a-developers-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.23-An-educational-illustration-explaining-the-importance-of-unique-namespace-prefixes-in-WordPress-REST-API-routes-to-avoid-conflicts.-Show-a-developers-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.23-An-educational-illustration-explaining-the-importance-of-unique-namespace-prefixes-in-WordPress-REST-API-routes-to-avoid-conflicts.-Show-a-developers-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.23-An-educational-illustration-explaining-the-importance-of-unique-namespace-prefixes-in-WordPress-REST-API-routes-to-avoid-conflicts.-Show-a-developers-768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.23-An-educational-illustration-explaining-the-importance-of-unique-namespace-prefixes-in-WordPress-REST-API-routes-to-avoid-conflicts.-Show-a-developers-12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.23-An-educational-illustration-explaining-the-importance-of-unique-namespace-prefixes-in-WordPress-REST-API-routes-to-avoid-conflicts.-Show-a-developers-96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>\u89e3\u6c7a\u7b56<\/strong> \u885d\u7a81\u3092\u907f\u3051\u308b\u305f\u3081\u306b\u3001\u4e00\u610f\u306a\u540d\u524d\u7a7a\u9593\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002REST API \u30eb\u30fc\u30c8\u306e\u540d\u524d\u7a7a\u9593\u306f\u3001\u3053\u306e\u3088\u3046\u306a\u885d\u7a81\u3092\u9632\u3050\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002\u305f\u3068\u3048\u3070<\/p><pre class=\"wp-block-code\"><code>register_rest_route('myplugin\/v1', '\/custom-content\/', array(\n    'methods' =&gt; 'GET'\u3001\n    'callback' =&gt; 'get_custom_content'\u3001\n    'permission_callback' =&gt; '__return_true'\u3001\n));<\/code><\/pre><p><strong>\u8aac\u660e<\/strong><\/p><ul class=\"wp-block-list\"><li>\u3092 <code>'myplugin\/v1'<\/code> \u540d\u524d\u7a7a\u9593\u306f\u540d\u524d\u306e\u885d\u7a81\u3092\u9632\u3050\u305f\u3081\u306b\u30eb\u30fc\u30c8\u3092\u4e00\u610f\u306b\u8b58\u5225\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/li>\n\n<li>\u7af6\u5408\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u7121\u52b9\u306b\u3057\u3066\u30c6\u30b9\u30c8\u3059\u308b\u3053\u3068\u3067\u3001\u7279\u5b9a\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u554f\u984c\u3092\u5f15\u304d\u8d77\u3053\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u7279\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li><\/ul><h4 class=\"wp-block-heading\">3.\u30d1\u30fc\u30de\u30ea\u30f3\u30af\u69cb\u9020\u304c\u6b63\u3057\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408<\/h4><p>WordPress REST API \u304c\u6b63\u3057\u304f\u6a5f\u80fd\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u30d1\u30fc\u30de\u30ea\u30f3\u30af\u69cb\u9020\u306b\u4f9d\u5b58\u3057\u307e\u3059\u3002\u3042\u306a\u305f\u306e\u30b5\u30a4\u30c8\u304c\u30d7\u30ec\u30fc\u30f3\u306a\u30d1\u30fc\u30de\u30ea\u30f3\u30af\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u5834\u5408\u3001REST API \u306e\u30eb\u30fc\u30c8\u306f\u5229\u7528\u3067\u304d\u306a\u3044\u304b\u3001\u671f\u5f85\u901a\u308a\u306b\u52d5\u4f5c\u3057\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p><p><strong>\u89e3\u6c7a\u7b56<\/strong> \u30d1\u30fc\u30de\u30ea\u30f3\u30af\u69cb\u9020\u3092\u66f4\u65b0\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002 <strong>\u8a2d\u5b9a &gt; \u30d1\u30fc\u30de\u30ea\u30f3\u30af<\/strong> \u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002Plain \"\u4ee5\u5916\u306e\u69cb\u9020\u3092\u9078\u629e\u3057\u3001\u5909\u66f4\u3092\u4fdd\u5b58\u3057\u307e\u3059\u3002\u3053\u308c\u3067\u30ea\u30e9\u30a4\u30c8\u30eb\u30fc\u30eb\u304c\u66f4\u65b0\u3055\u308c\u3001REST API \u30eb\u30fc\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.34-An-informative-illustration-showing-the-importance-of-setting-the-correct-permalink-structure-in-WordPress-for-REST-API-functionality.-Show-a-WordPres.webp\" alt=\"\" class=\"wp-image-4325\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.34-An-informative-illustration-showing-the-importance-of-setting-the-correct-permalink-structure-in-WordPress-for-REST-API-functionality.-Show-a-WordPres.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.34-An-informative-illustration-showing-the-importance-of-setting-the-correct-permalink-structure-in-WordPress-for-REST-API-functionality.-Show-a-WordPres-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.34-An-informative-illustration-showing-the-importance-of-setting-the-correct-permalink-structure-in-WordPress-for-REST-API-functionality.-Show-a-WordPres-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.34-An-informative-illustration-showing-the-importance-of-setting-the-correct-permalink-structure-in-WordPress-for-REST-API-functionality.-Show-a-WordPres-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.34-An-informative-illustration-showing-the-importance-of-setting-the-correct-permalink-structure-in-WordPress-for-REST-API-functionality.-Show-a-WordPres-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.34-An-informative-illustration-showing-the-importance-of-setting-the-correct-permalink-structure-in-WordPress-for-REST-API-functionality.-Show-a-WordPres-768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.34-An-informative-illustration-showing-the-importance-of-setting-the-correct-permalink-structure-in-WordPress-for-REST-API-functionality.-Show-a-WordPres-12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.37.34-An-informative-illustration-showing-the-importance-of-setting-the-correct-permalink-structure-in-WordPress-for-REST-API-functionality.-Show-a-WordPres-96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><h4 class=\"wp-block-heading\">4.\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u554f\u984c<\/h4><p>\u30ad\u30e3\u30c3\u30b7\u30e5\u30d7\u30e9\u30b0\u30a4\u30f3\u3084\u30b5\u30fc\u30d0\u30fc\u30ec\u30d9\u30eb\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u306fREST API\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u9069\u5207\u306a\u6a5f\u80fd\u3092\u59a8\u3052\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u6709\u52b9\u306a\u5834\u5408\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3078\u306e\u5909\u66f4\u304c\u5373\u5ea7\u306b\u53cd\u6620\u3055\u308c\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002 <code>rest_api_init<\/code> \u304c\u6a5f\u80fd\u3057\u3066\u3044\u307e\u305b\u3093\u3002<\/p><p><strong>\u89e3\u6c7a\u7b56<\/strong> \u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\uff08Varnish\u3084Nginx\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u306a\u3069\uff09\u3068WordPress\u30ec\u30d9\u30eb\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4e21\u65b9\u3067\u3001\u30ad\u30e3\u30c3\u30b7\u30e5\u6a5f\u69cb\u3092\u30af\u30ea\u30a2\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u958b\u767a\u74b0\u5883\u3067\u306f\u3001\u958b\u767a\u4e2d\u3084\u30c6\u30b9\u30c8\u4e2d\u306e\u554f\u984c\u3092\u907f\u3051\u308b\u305f\u3081\u306b\u3001\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u5b8c\u5168\u306b\u7121\u52b9\u306b\u3059\u308b\u3053\u3068\u3092\u691c\u8a0e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.44.55-An-educational-illustration-focusing-on-resolving-caching-issues-and-permission-callback-errors-in-WordPress-REST-API-development.-Show-a-workspace-wi.webp\" alt=\"\" class=\"wp-image-4331\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.44.55-An-educational-illustration-focusing-on-resolving-caching-issues-and-permission-callback-errors-in-WordPress-REST-API-development.-Show-a-workspace-wi.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.44.55-An-educational-illustration-focusing-on-resolving-caching-issues-and-permission-callback-errors-in-WordPress-REST-API-development.-Show-a-workspace-wi-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.44.55-An-educational-illustration-focusing-on-resolving-caching-issues-and-permission-callback-errors-in-WordPress-REST-API-development.-Show-a-workspace-wi-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.44.55-An-educational-illustration-focusing-on-resolving-caching-issues-and-permission-callback-errors-in-WordPress-REST-API-development.-Show-a-workspace-wi-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.44.55-An-educational-illustration-focusing-on-resolving-caching-issues-and-permission-callback-errors-in-WordPress-REST-API-development.-Show-a-workspace-wi-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.44.55-An-educational-illustration-focusing-on-resolving-caching-issues-and-permission-callback-errors-in-WordPress-REST-API-development.-Show-a-workspace-wi-768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.44.55-An-educational-illustration-focusing-on-resolving-caching-issues-and-permission-callback-errors-in-WordPress-REST-API-development.-Show-a-workspace-wi-12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.44.55-An-educational-illustration-focusing-on-resolving-caching-issues-and-permission-callback-errors-in-WordPress-REST-API-development.-Show-a-workspace-wi-96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><h4 class=\"wp-block-heading\">5.\u4e0d\u6b63\u306a\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u30b3\u30fc\u30eb\u30d0\u30c3\u30af<\/h4><p>\u3092 <code>\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3_\u30b3\u30fc\u30eb\u30d0\u30c3\u30af<\/code> \u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u3001\u30e6\u30fc\u30b6\u304c REST API \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u65ad\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u304c false \u3092\u8fd4\u3057\u305f\u308a\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u308a\u3059\u308b\u3068\u3001\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u304f\u306a\u308a\u307e\u3059\u3002 <code>rest_api_init<\/code> \u3046\u307e\u304f\u3044\u304b\u306a\u3044<\/p><p><strong>\u89e3\u6c7a\u7b56<\/strong> \u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002 <code>\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3_\u30b3\u30fc\u30eb\u30d0\u30c3\u30af<\/code> \u95a2\u6570\u306f\u6b63\u3057\u304f\u5b9f\u88c5\u3055\u308c <code>\u771f\u306e<\/code> \u30a2\u30af\u30bb\u30b9\u304c\u8a31\u53ef\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3002\u4f8b\u3048\u3070<\/p><pre class=\"wp-block-code\"><code>\u95a2\u6570 get_custom_content_permission() {\n    return current_user_can('read'); \/\/ \u5fc5\u8981\u306b\u5fdc\u3058\u3066\u6a29\u9650\u3092\u8abf\u6574\u3057\u307e\u3059\u3002\n}\n\nadd_action('rest_api_init', 'register_custom_api_routes')\uff1b\n\n\u95a2\u6570 register_custom_api_routes() {\n    register_rest_route('myplugin\/v1', '\/custom-content\/', array(\n        'methods' =&gt; 'GET'\u3001\n        'callback' =&gt; 'get_custom_content'\u3001\n        'permission_callback' =&gt; 'get_custom_content_permission'\u3001\n    ));\n}<\/code><\/pre><p><strong>\u8aac\u660e<\/strong><\/p><ul class=\"wp-block-list\"><li><code>current_user_can('read')<\/code> \u306f\u3001\u73fe\u5728\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u9069\u5207\u306a\u6a29\u9650\u3092\u6301\u3063\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u5fdc\u3058\u3066\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u80fd\u529b\u3092\u8abf\u6574\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n\n<li>\u5fc5\u8981\u306a\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u3092\u6301\u305f\u306a\u3044\u30e6\u30fc\u30b6\u30fc\u304c\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/li><\/ul><h4 class=\"wp-block-heading\">6.\u30c7\u30d0\u30c3\u30b0\u30c4\u30fc\u30eb\u3068\u30c6\u30af\u30cb\u30c3\u30af<\/h4><p>REST API\u306e\u554f\u984c\u3092\u30c7\u30d0\u30c3\u30b0\u3059\u308b\u306e\u306f\u3001\u9069\u5207\u306a\u30c4\u30fc\u30eb\u304c\u306a\u3044\u3068\u96e3\u3057\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u30c7\u30d0\u30c3\u30b0\u306e\u65b9\u6cd5\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002 <code>rest_api_init<\/code> \u304c\u6a5f\u80fd\u3057\u3066\u3044\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\uff1a<\/p><ul class=\"wp-block-list\"><li><strong>WordPress\u306e\u30c7\u30d0\u30c3\u30b0\u30e2\u30fc\u30c9<\/strong>:WordPress\u306e\u30c7\u30d0\u30c3\u30b0\u30e2\u30fc\u30c9\u3092\u6709\u52b9\u306b\u3059\u308b\u306b\u306f <code>define('WP_DEBUG', true)\uff1b<\/code> \u3042\u306a\u305f\u306e <code>wp-config.php<\/code> \u30d5\u30a1\u30a4\u30eb\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u30b3\u30fc\u30c9\u306e\u30a8\u30e9\u30fc\u3092\u7279\u5b9a\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002 <code>rest_api_init<\/code> \u3092\u6b63\u3057\u304f\u767a\u5c04\u3067\u304d\u307e\u305b\u3093\u3002<\/li>\n\n<li><strong>\u30c6\u30b9\u30c8\u306b\u30dd\u30b9\u30c8\u30de\u30f3\u3092\u4f7f\u7528<\/strong>:Postman \u306f REST API \u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u30c6\u30b9\u30c8\u3059\u308b\u305f\u3081\u306e\u512a\u308c\u305f\u30c4\u30fc\u30eb\u3067\u3059\u3002\u30ab\u30b9\u30bf\u30e0\u30eb\u30fc\u30c8\u3092\u30c6\u30b9\u30c8\u3059\u308b\u306b\u306f\u3001\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8 URL \u306b GET \u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3057\u307e\u3059 (\u4f8b\u3001 <code>http:\/\/yourdomain.com\/wp-json\/myplugin\/v1\/custom-content<\/code>).\u3053\u308c\u306f\u3001\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u304c\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u304b\u3069\u3046\u304b\u3001\u671f\u5f85\u901a\u308a\u306e\u30c7\u30fc\u30bf\u3092\u8fd4\u3059\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<ul class=\"wp-block-list\"><li><strong>\u30b9\u30c6\u30c3\u30d7\u30fb\u30d0\u30a4\u30fb\u30b9\u30c6\u30c3\u30d7\u306e\u30dd\u30b9\u30c8\u30de\u30f3\u30fb\u30c6\u30b9\u30c8<\/strong>:<ol start=\"1\" class=\"wp-block-list\"><li>Postman\u3092\u958b\u304d\u3001\u65b0\u3057\u3044GET\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/li>\n\n<li>API\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306eURL\u3092\u5165\u529b\u3057\u307e\u3059\u3001 <code>http:\/\/yourdomain.com\/wp-json\/myplugin\/v1\/custom-content<\/code>).<\/li>\n\n<li>\u9001\u4fe1\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u958b\u59cb\u3057\u307e\u3059\u3002<\/li>\n\n<li>\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u3068\u30c7\u30fc\u30bf\u3092\u89b3\u5bdf\u3057\u3066\u304f\u3060\u3055\u3044\u3002200 OK\u30b9\u30c6\u30fc\u30bf\u30b9\u306f\u6210\u529f\u3092\u793a\u3057\u3001404\u3084403\u306f\u30eb\u30fc\u30c8\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u3001\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u306a\u3069\u306e\u554f\u984c\u3092\u793a\u3057\u307e\u3059\u3002<\/li>\n\n<li>\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u8a8d\u8a3c\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u3001\u5236\u9650\u3055\u308c\u305f\u30eb\u30fc\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306e\u8a8d\u8a3c\u30c8\u30fc\u30af\u30f3\u306a\u3069\u3001\u5fc5\u8981\u306a\u30d8\u30c3\u30c0\u3092\u542b\u3081\u307e\u3059\u3002<\/li><\/ol><\/li><\/ul><\/li>\n\n<li><strong>WordPress REST API \u30b3\u30f3\u30bd\u30fc\u30eb\u30d7\u30e9\u30b0\u30a4\u30f3<\/strong>:REST API Console \u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u7ba1\u7406\u753b\u9762\u304b\u3089 WordPress REST API \u3092\u76f4\u63a5\u64cd\u4f5c\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306f\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306e\u30c7\u30d0\u30c3\u30b0\u3084\u30ab\u30b9\u30bf\u30e0\u30eb\u30fc\u30c8\u304c\u6b63\u3057\u304f\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u304b\u306e\u30c1\u30a7\u30c3\u30af\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/li>\n\n<li><strong>\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30c6\u30b9\u30c8\u306e\u305f\u3081\u306ecURL<\/strong>:\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089cURL\u3092\u4f7f\u7528\u3057\u3066\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u30c6\u30b9\u30c8\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\uff1a<code>curl -X GET \"http:\/\/yourdomain.com\/wp-json\/myplugin\/v1\/custom-content\"<\/code><strong>\u8aac\u660e<\/strong> \u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b GET \u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30eb\u30fc\u30c8\u304c\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30ec\u30d9\u30eb\u306e\u554f\u984c\u3092\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5fdc\u7b54\u30d8\u30c3\u30c0\u3068\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li><\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.40.11-An-instructional-illustration-showing-various-debugging-tools-and-techniques-for-troubleshooting-WordPress-REST-API-issues-specifically-focusing-on-t.webp\" alt=\"\" class=\"wp-image-4327\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.40.11-An-instructional-illustration-showing-various-debugging-tools-and-techniques-for-troubleshooting-WordPress-REST-API-issues-specifically-focusing-on-t.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.40.11-An-instructional-illustration-showing-various-debugging-tools-and-techniques-for-troubleshooting-WordPress-REST-API-issues-specifically-focusing-on-t-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.40.11-An-instructional-illustration-showing-various-debugging-tools-and-techniques-for-troubleshooting-WordPress-REST-API-issues-specifically-focusing-on-t-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.40.11-An-instructional-illustration-showing-various-debugging-tools-and-techniques-for-troubleshooting-WordPress-REST-API-issues-specifically-focusing-on-t-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.40.11-An-instructional-illustration-showing-various-debugging-tools-and-techniques-for-troubleshooting-WordPress-REST-API-issues-specifically-focusing-on-t-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.40.11-An-instructional-illustration-showing-various-debugging-tools-and-techniques-for-troubleshooting-WordPress-REST-API-issues-specifically-focusing-on-t-768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.40.11-An-instructional-illustration-showing-various-debugging-tools-and-techniques-for-troubleshooting-WordPress-REST-API-issues-specifically-focusing-on-t-12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.40.11-An-instructional-illustration-showing-various-debugging-tools-and-techniques-for-troubleshooting-WordPress-REST-API-issues-specifically-focusing-on-t-96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><h3 class=\"wp-block-heading\">WPML\u3068Polylang\u306e\u8a73\u7d30\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u7d71\u5408\u624b\u9806<\/h3><p>\u30ab\u30b9\u30bf\u30e0REST API\u3092\u591a\u8a00\u8a9e\u5316\u3059\u308b\u305f\u3081\u306b\u3001WPML\u3084Polylang\u306e\u3088\u3046\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u3053\u308c\u3089\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u306f\u7ffb\u8a33\u306e\u305f\u3081\u306e\u5305\u62ec\u7684\u306a\u30c4\u30fc\u30eb\u3092\u63d0\u4f9b\u3057\u307e\u3059\u304c\u3001\u30ab\u30b9\u30bf\u30e0REST API\u30eb\u30fc\u30c8\u3068\u9069\u5207\u306b\u7d71\u5408\u3059\u308b\u306b\u306f\u7279\u5b9a\u306e\u624b\u9806\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p><h4 class=\"wp-block-heading\">WPML\u306e\u7d71\u5408<\/h4><ol start=\"1\" class=\"wp-block-list\"><li><strong>WPML\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong>:WPML\u30d7\u30e9\u30b0\u30a4\u30f3\u3092WordPress\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u307e\u305f\u306fWPML\u306e\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u6709\u52b9\u5316\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n\n<li><strong>\u8a00\u8a9e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306e\u5207\u308a\u66ff\u3048<\/strong>:\u7528\u9014 <code>\u30b0\u30ed\u30fc\u30d0\u30eb$sitepress\uff1b<\/code> \u305d\u3057\u3066 <code>$sitepress-&gt;switch_lang($language)\uff1b<\/code> \u3092\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u306b\u8ffd\u52a0\u3057\u3066\u3001 \u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u554f\u3044\u5408\u308f\u305b\u308b\u524d\u306b\u8a00\u8a9e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/li>\n\n<li><strong>REST API\u30eb\u30fc\u30c8\u306e\u767b\u9332<\/strong>:\u3092\u9069\u5207\u306b\u51e6\u7406\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002 <code>\u30e9\u30f3\u30b0<\/code> \u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u52d5\u7684\u306b\u8a00\u8a9e\u3092\u5207\u308a\u66ff\u3048\u3066\u304b\u3089\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u8fd4\u3057\u307e\u3059\uff1a<code>function get_content_by_language($language) { global $sitepress; $sitepress-&gt;switch_lang($language); $args = array( 'post_type' =&gt; 'post', 'posts_per_page' =&gt; 5 ); $query = new WP_Query($args); return $query-&gt;posts; }.<\/code><strong>\u8aac\u660e<\/strong> \u3053\u306e\u95a2\u6570\u306f\u3001\u6295\u7a3f\u3092\u30af\u30a8\u30ea\u3059\u308b\u524d\u306b WPML \u306e API \u3092\u4f7f\u7528\u3057\u3066\u8a00\u8a9e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u5207\u308a\u66ff\u3048\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\u76ee\u7684\u306e\u8a00\u8a9e\u3067\u53d6\u5f97\u3055\u308c\u308b\u3053\u3068\u3092\u4fdd\u8a3c\u3057\u307e\u3059\u3002<\/li><\/ol><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.41.08-A-detailed-illustration-showing-steps-to-integrate-WPML-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Depict-a-developer-workspace-w.webp\" alt=\"\" class=\"wp-image-4328\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.41.08-A-detailed-illustration-showing-steps-to-integrate-WPML-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Depict-a-developer-workspace-w.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.41.08-A-detailed-illustration-showing-steps-to-integrate-WPML-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Depict-a-developer-workspace-w-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.41.08-A-detailed-illustration-showing-steps-to-integrate-WPML-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Depict-a-developer-workspace-w-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.41.08-A-detailed-illustration-showing-steps-to-integrate-WPML-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Depict-a-developer-workspace-w-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.41.08-A-detailed-illustration-showing-steps-to-integrate-WPML-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Depict-a-developer-workspace-w-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.41.08-A-detailed-illustration-showing-steps-to-integrate-WPML-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Depict-a-developer-workspace-w-768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.41.08-A-detailed-illustration-showing-steps-to-integrate-WPML-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Depict-a-developer-workspace-w-12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.41.08-A-detailed-illustration-showing-steps-to-integrate-WPML-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Depict-a-developer-workspace-w-96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><h4 class=\"wp-block-heading\">Polylang\u306e\u7d71\u5408<\/h4><ol start=\"1\" class=\"wp-block-list\"><li><strong>Polylang\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong>:Polylang\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u6709\u52b9\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n\n<li><strong>pll_set_language() \u306b\u3088\u308b\u8a00\u8a9e\u8a2d\u5b9a<\/strong>:\u7528\u9014 <code>pll_set_language($language)\uff1b<\/code> \u3092\u4f7f\u7528\u3057\u3066\u3001API\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u5185\u3067\u8a00\u8a9e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/li>\n\n<li><strong>\u8a00\u8a9e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u53cd\u6620\u3057\u305f\u30af\u30a8\u30ea\u306e\u4fee\u6b63<\/strong>:\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u7167\u4f1a\u3059\u308b\u969b\u306b\u3001\u8a00\u8a9e\u304c\u5fc5\u8981\u306a\u5024\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\uff1a<code>function get_content_by_language($language) { pll_set_language($language); $args = array( 'post_type' =&gt; 'post', 'posts_per_page' =&gt; 5 ); $query = new WP_Query($args); return $query-&gt;posts; }.<\/code><strong>\u8aac\u660e<\/strong> \u3092 <code>pll_set_language($language)<\/code> \u95a2\u6570\u306f\u3001\u30b3\u30f3\u30c6\u30f3\u30c4\u30af\u30a8\u30ea\u306b\u5fc5\u8981\u306a\u8a00\u8a9e\u3092\u8a2d\u5b9a\u3057\u3001\u6b63\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\u8fd4\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/li><\/ol><h3 class=\"wp-block-heading\">\u5b9f\u4f8b\uff1a\u591a\u8a00\u8a9e\u30d6\u30ed\u30b0API\u306e\u4f5c\u6210<\/h3><p>\u3092\u4f7f\u3063\u3066\u7c21\u5358\u306a\u591a\u8a00\u8a9e\u30d6\u30ed\u30b0API\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002 <code>rest_api_init<\/code>.\u3053\u306eAPI\u306f\u3001WPML\u3092\u4f7f\u7528\u3057\u3066\u7570\u306a\u308b\u8a00\u8a9e\u3067\u306e\u6295\u7a3f\u306e\u30af\u30a8\u30ea\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.42.36-An-informative-illustration-showing-steps-to-integrate-Polylang-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Display-a-developer-wo.webp\" alt=\"\" class=\"wp-image-4329\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.42.36-An-informative-illustration-showing-steps-to-integrate-Polylang-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Display-a-developer-wo.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.42.36-An-informative-illustration-showing-steps-to-integrate-Polylang-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Display-a-developer-wo-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.42.36-An-informative-illustration-showing-steps-to-integrate-Polylang-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Display-a-developer-wo-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.42.36-An-informative-illustration-showing-steps-to-integrate-Polylang-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Display-a-developer-wo-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.42.36-An-informative-illustration-showing-steps-to-integrate-Polylang-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Display-a-developer-wo-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.42.36-An-informative-illustration-showing-steps-to-integrate-Polylang-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Display-a-developer-wo-768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.42.36-An-informative-illustration-showing-steps-to-integrate-Polylang-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Display-a-developer-wo-12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.42.36-An-informative-illustration-showing-steps-to-integrate-Polylang-with-custom-WordPress-REST-API-routes-for-multilingual-support.-Display-a-developer-wo-96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>\u30b9\u30c6\u30c3\u30d71: REST\u30eb\u30fc\u30c8\u306e\u767b\u9332<\/strong><\/p><pre class=\"wp-block-code\"><code>add_action('rest_api_init', 'register_multilingual_blog_routes')\uff1b\n\n\u95a2\u6570 register_multilingual_blog_routes() {\n    register_rest_route('myblog\/v1', '\/posts\/', array(\n        'methods' =&gt; 'GET'\u3001\n        'callback' =&gt; 'get_blog_posts_by_language'\u3001\n        'permission_callback' =&gt; '__return_true'\u3001\n    ));\n}<\/code><\/pre><p><strong>\u30b9\u30c6\u30c3\u30d7 2: \u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u306e\u5b9a\u7fa9<\/strong><\/p><pre class=\"wp-block-code\"><code>function get_blog_posts_by_language($request) { { { get_blog_posts_by_language($request)\n    $language = $request-&gt;get_param('lang')\uff1b\n    \n    if (!$language) { { {.\n        return new WP_Error('no_language', 'Language parameter is required', array('status' =&gt; 400))\uff1b\n    }\n    \n    global $sitepress\uff1b\n    $sitepress-&gt;switch_lang($language)\uff1b\n    \n    $args = array(\n        'post_type' =&gt; 'post'\u3001\n        'posts_per_page' =&gt; 5\n    );\n    \n    $query = new WP_Query($args)\uff1b\n    \n    if (empty($query-&gt;posts)) {\n        return new WP_Error('no_posts', 'No posts found for the specified language', array('status' =&gt; 404))\uff1b\n    }\n    \n    return rest_ensure_response($query-&gt;posts)\uff1b\n}<\/code><\/pre><p><strong>\u8aac\u660e<\/strong><\/p><ul class=\"wp-block-list\"><li>\u3053\u306e\u4f8b\u3067\u306f\u3001REST API \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 <code>\/wp-json\/myblog\/v1\/posts\/<\/code> \u8a00\u8a9e\u30d1\u30e9\u30e1\u30fc\u30bf (<code>\u30e9\u30f3\u30b0<\/code>).<\/li>\n\n<li>\u3092 <code>\u8a00\u8a9e\u5225\u30d6\u30ed\u30b0\u8a18\u4e8b\u53d6\u5f97<\/code> \u95a2\u6570\u306f\u3001WPML \u3092\u4f7f\u7528\u3057\u3066\u8a00\u8a9e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u5207\u308a\u66ff\u3048\u3001\u305d\u308c\u306b\u5fdc\u3058\u3066\u6295\u7a3f\u3092\u30af\u30a8\u30ea\u3057\u307e\u3059\u3002<\/li>\n\n<li>\u9069\u5207\u306a\u30a8\u30e9\u30fc\u51e6\u7406\u306f\u3001\u8a00\u8a9e\u3084\u6295\u7a3f\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306b\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u304c\u610f\u5473\u306e\u3042\u308b\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059\u3088\u3046\u306b\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/li><\/ul><h3 class=\"wp-block-heading\">\u7d50\u8ad6<\/h3><p>\u3092 <code>rest_api_init<\/code> \u30d5\u30c3\u30af\u306f WordPress REST API \u3092\u62e1\u5f35\u3059\u308b\u305f\u3081\u306e\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u304c\u3001\u305d\u306e\u9069\u5207\u306a\u5b9f\u88c5\u306b\u306f\u3001\u30bf\u30a4\u30df\u30f3\u30b0\u3001\u7af6\u5408\u3001\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u3001\u30c7\u30d0\u30c3\u30b0\u624b\u6cd5\u3092\u614e\u91cd\u306b\u8003\u616e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30d5\u30c3\u30af\u3092\u6b63\u3057\u304f\u914d\u7f6e\u3057\u3001\u6f5c\u5728\u7684\u306a\u7af6\u5408\u3092\u7ba1\u7406\u3057\u3001\u30d1\u30fc\u30de\u30ea\u30f3\u30af\u306e\u5f79\u5272\u3092\u7406\u89e3\u3057\u3001\u5805\u7262\u306a\u30c7\u30d0\u30c3\u30b0\u65b9\u6cd5\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30ab\u30b9\u30bf\u30e0 REST API \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u52b9\u679c\u7684\u306b\u52d5\u4f5c\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.43.34-A-concluding-illustration-summarizing-best-practices-for-using-rest_api_init-in-WordPress-REST-API-development.-Show-a-professional-workspace-with-a.webp\" alt=\"\" class=\"wp-image-4330\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.43.34-A-concluding-illustration-summarizing-best-practices-for-using-rest_api_init-in-WordPress-REST-API-development.-Show-a-professional-workspace-with-a.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.43.34-A-concluding-illustration-summarizing-best-practices-for-using-rest_api_init-in-WordPress-REST-API-development.-Show-a-professional-workspace-with-a-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.43.34-A-concluding-illustration-summarizing-best-practices-for-using-rest_api_init-in-WordPress-REST-API-development.-Show-a-professional-workspace-with-a-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.43.34-A-concluding-illustration-summarizing-best-practices-for-using-rest_api_init-in-WordPress-REST-API-development.-Show-a-professional-workspace-with-a-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.43.34-A-concluding-illustration-summarizing-best-practices-for-using-rest_api_init-in-WordPress-REST-API-development.-Show-a-professional-workspace-with-a-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.43.34-A-concluding-illustration-summarizing-best-practices-for-using-rest_api_init-in-WordPress-REST-API-development.-Show-a-professional-workspace-with-a-768x768.webp 768w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.43.34-A-concluding-illustration-summarizing-best-practices-for-using-rest_api_init-in-WordPress-REST-API-development.-Show-a-professional-workspace-with-a-12x12.webp 12w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-29-11.43.34-A-concluding-illustration-summarizing-best-practices-for-using-rest_api_init-in-WordPress-REST-API-development.-Show-a-professional-workspace-with-a-96x96.webp 96w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p>\u3055\u3089\u306b\u3001WPML \u3084 Polylang \u306e\u3088\u3046\u306a\u591a\u8a00\u8a9e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30ab\u30b9\u30bf\u30e0 API \u306b\u7d71\u5408\u3059\u308b\u306b\u306f\u3001\u6b63\u3057\u3044\u8a00\u8a9e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u304c\u9069\u7528\u3055\u308c\u308b\u3088\u3046\u306b\u7d30\u90e8\u306b\u6ce8\u610f\u3092\u6255\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3068\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u30c6\u30af\u30cb\u30c3\u30af\u306b\u5f93\u3046\u3053\u3068\u3067\u3001REST API \u3092\u62e1\u5f35\u3059\u308b WordPress \u306e\u30ab\u30b9\u30bf\u30e0\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u958b\u767a\u3059\u308b\u969b\u306e\u6642\u9593\u3068\u982d\u75db\u306e\u7a2e\u3092\u6e1b\u3089\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p><p>\u3082\u3057\u3042\u306a\u305f\u304c\u307e\u3060 <code>rest_api_init<\/code> \u304c\u52d5\u4f5c\u3057\u306a\u3044\u5834\u5408\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f53\u7cfb\u7684\u306b\u7121\u52b9\u306b\u3057\u3001Postman \u3084 REST API Console \u306e\u3088\u3046\u306a\u30c7\u30d0\u30c3\u30b0\u30c4\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u3001\u74b0\u5883\u304c REST API \u958b\u767a\u306b\u5fc5\u8981\u306a\u3059\u3079\u3066\u306e\u8981\u4ef6\u3092\u6e80\u305f\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p><p>WordPress \u3067\u30ab\u30b9\u30bf\u30e0 REST API \u30eb\u30fc\u30c8\u3092\u52d5\u4f5c\u3055\u305b\u308b\u305f\u3081\u306e\u3054\u8cea\u554f\u3084\u30b5\u30dd\u30fc\u30c8\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306b\u30b3\u30e1\u30f3\u30c8\u3092\u6b8b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u30ab\u30b9\u30bf\u30e0WordPress\u30d7\u30e9\u30b0\u30a4\u30f3\u3067rest_api_init\u304c\u52d5\u4f5c\u3057\u306a\u3044\u554f\u984c\u306b\u906d\u9047\u3059\u308b\u3068\u3001\u7279\u306b\u3001\u3059\u3079\u3066\u304c\u6b63\u3057\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u306b\u898b\u3048\u308b\u3068\u304d\u306b\u3001\u304b\u306a\u308a\u30a4\u30e9\u30a4\u30e9\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>","protected":false},"author":31,"featured_media":4317,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,78],"tags":[375,376,220],"class_list":["post-4319","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-rest-api","category-rest-api-use","tag-rest-api","tag-rest_api_init","tag-wordpress",""],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/posts\/4319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/users\/31"}],"replies":[{"embeddable":true,"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/comments?post=4319"}],"version-history":[{"count":1,"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/posts\/4319\/revisions"}],"predecessor-version":[{"id":4332,"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/posts\/4319\/revisions\/4332"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/media\/4317"}],"wp:attachment":[{"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/media?parent=4319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/categories?post=4319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.openbyt.com\/ja\/wp-json\/wp\/v2\/tags?post=4319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}