{"id":12307,"date":"2024-02-11T07:00:56","date_gmt":"2024-02-10T22:00:56","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=12307"},"modified":"2024-02-13T04:02:08","modified_gmt":"2024-02-12T19:02:08","slug":"wordpress-%e3%81%ab-chatgpt-%e3%81%a7%e3%81%a4%e3%81%8f%e3%81%a3%e3%81%9f%e3%80%8c%e4%b8%89%e8%a1%8c%e8%a6%81%e7%b4%84%e3%80%8d%e3%82%92%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=12307","title":{"rendered":"wordpress \u306b ChatGPT \u3067\u3064\u304f\u3063\u305f\u300c\u4e09\u884c\u8981\u7d04\u300d\u3092\u8868\u793a\u3059\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u6700\u8fd1\u306f\u30db\u30f3\u30c8\u306b\u5909\u5316\u306e\u65e9\u3044\u6642\u4ee3\u3067\u3059\u304b\u3089\u60c5\u5831\u53ce\u96c6\u304c\u304b\u304b\u305b\u306a\u3044\u306e\u3067\u3001\u3067\u304d\u308b\u3060\u3051\u304d\u3061\u3093\u3068\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u3093\u306a\u300c\u60c5\u5831\u904e\u591a\u300d\u306b\u306a\u308a\u304c\u3061\u306a\u6211\u3005\u306b\u5b09\u3057\u3044\u306e\u304c\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">\u4e09\u884c\u8981\u7d04<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u9577\u3044\u8a18\u4e8b\u3092\u8aad\u3080\u524d\u306b\u300c\u3060\u3044\u305f\u3044\u3053\u3093\u306a\u8a18\u4e8b\u3060\u3088\u300d\u3068\u6559\u3048\u3066\u304f\u308c\u308b\u6a5f\u80fd\u3067\u3059\u306d\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u305d\u3046\u8003\u3048\u3066\u3044\u308b\u3068\u300c<strong>\u3042\u30fc\u3001\u3082\u3057\u304b\u3059\u308b\u3068\u3053\u306e\u30d6\u30ed\u30b0\u3082\u4e09\u884c\u8981\u7d04\u304c\u3042\u3063\u305f\u65b9\u304c\u3044\u3044\u306e\u304b\u306a\u2026\ud83e\udd14<\/strong>\u300d\u306a\u3093\u3066\u8003\u3048\u3066\u3044\u308b\u3068\u3072\u3068\u3064\u3084\u3063\u3066\u307f\u305f\u3044\u3053\u3068\u304c\u6d6e\u304b\u3073\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u304c\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">wordpress \u306b\u3082\u4e09\u884c\u8981\u7d04\u306e\u6a5f\u80fd\u3092\u3064\u3051\u308b<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u2757<\/p>\n<p>\u4eca\u56de\u306f<code>wordpress<\/code>\u306b\u5b50\u30c6\u30fc\u30de\u3092\u3064\u304f\u3063\u3066\u81ea\u52d5\u7684\u306b\u4e09\u884c\u8981\u7d04\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u4f55\u304b\u306e\u53c2\u8003\u306b\u306a\u308a\u307e\u3057\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\u3002\ud83d\ude04\u2728<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4328 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_3.png\" alt=\"\" width=\"364\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_3.png 364w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_3-300x264.png 300w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/>\u300c\u500b\u4eba\u7684\u306a\u5199\u771f\u304c\u6d88\u3048\u3066\u3057\u307e\u3044\u3001<br \/>\nGoogle \u30d5\u30a9\u30c8\u304b\u3089\u5fa9\u65e7\u4e2d\u3067\u3059\u2026\ud83d\ude2b\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> wordpress 6.4\u3001PHP 8.2<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u4eca\u56de\u306f\u8a18\u4e8b\u306e\u30da\u30fc\u30b8\u306e\u307f\u3092\u4e09\u884c\u8981\u7d04\u3057\u3066\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u6bce\u56de\u6bce\u56de<code>API<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u304a\u91d1\u304c\u304b\u304b\u308b\u306e\u3067\u3001\u4e00\u56de\u8981\u7d04\u3057\u305f\u3082\u306e\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u3057\u3066\u304a\u304d\u3001\u6b21\u56de\u304b\u3089\u306f<code>API<\/code>\u30a2\u30af\u30bb\u30b9\u3092\u30b7\u30e7\u30fc\u30c8\u30ab\u30c3\u30c8\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u4eca\u56de\u3082\u697d\u3057\u3093\u3067\u3084\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u2757<\/p>\n<h1>\u524d\u63d0\u3068\u3057\u3066<\/h1>\n<p><code>ChatGPT<\/code>\uff08<code>OpenAI<\/code>\uff09<code>API<\/code>\u306e\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u3092\u3059\u3067\u306b\u53d6\u5f97\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u524d\u63d0\u3067\u3059\u3002<\/p>\n<p>\u3082\u3057\u307e\u3060\u306e\u65b9\u306f\u4ee5\u4e0b\u306e\u53c2\u8003\u30da\u30fc\u30b8\u3092\u898b\u3066\u5148\u306b\u6e96\u5099\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\ud83d\udcdd<strong> \u53c2\u8003\u30da\u30fc\u30b8\uff1a<\/strong> <a href=\"https:\/\/blog.capilano-fw.com\/?p=11642#OpenAI_API\" target=\"_blank\" rel=\"noopener\">ChatGPT API\u306e\u767b\u9332<\/a><\/p>\n<h1>\u5b50\u30c6\u30fc\u30de\u3092\u3064\u304f\u308b<\/h1>\n<p>\u4eca\u56de\u306f\u3001<code>wordpress<\/code>\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u5834\u5408\u306b\u3088\u304f\u4f7f\u308f\u308c\u308b\u300c<strong>\u5b50\u30c6\u30fc\u30de<\/strong>\u300d\u3092\u3064\u304f\u308b\u3084\u308a\u65b9\u3067\u3059\u3002<\/p>\n<p>\u5b50\u30c6\u30fc\u30de\u3092\u4f5c\u3063\u3066\u304a\u304f\u3068\u3001\u6539\u9020\u3057\u305f\u90e8\u5206\u306f\u4e0a\u66f8\u304d\u3055\u308c\u306a\u304f\u306a\u308b\u3001\u3064\u307e\u308a\u3001\u300c<strong>\u5909\u66f4\u3055\u308c\u305f\u3089\u56f0\u308b\u30d5\u30a1\u30a4\u30eb\u306f\u305a\u3063\u3068\u305d\u306e\u307e\u307e<\/strong>\u300d\u4f5c\u6226\u3067\u3059\u306d\u3002<\/p>\n<p>\u3067\u306f\u3001\u4eca\u56de\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u5b58\u5728\u3057\u3066\u3044\u308b\u300c<strong>twentytwentyfour<\/strong>\u300d\u3068\u3044\u3046\u30c6\u30fc\u30de\u306e\u5b50\u30c6\u30fc\u30de\u3068\u3057\u3066\u300c<strong>twentytwentyfour-with-summary<\/strong>\u300d\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u307e\u305a\u306f<code>\/wp-content\/themes\/<\/code>\u306e\u4e2d\u306b<code>twentytwentyfour-with-summary<\/code>\u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u3092\u3064\u304f\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12308\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_1.png\" alt=\"\" width=\"640\" height=\"181\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_1.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_1-300x85.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u4e2d\u306b\u4eca\u56de\u306f\u4ee5\u4e0b\uff12\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f\u3057\u307e\u3059\u3002\uff08\u73fe\u6642\u70b9\u3067\u306f\u7a7a\u306e\u30d5\u30a1\u30a4\u30eb\u3067OK\u3067\u3059\uff09<\/p>\n<ul>\n<li>functions.php<\/li>\n<li>style.css<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12309\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_2.png\" alt=\"\" width=\"428\" height=\"206\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_2.png 428w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_2-300x144.png 300w\" sizes=\"auto, (max-width: 428px) 100vw, 428px\" \/><\/p>\n<p>\u3067\u306f\u3001\u305d\u308c\u305e\u308c\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h1>style.css \u3092\u3064\u304f\u308b<\/h1>\n<p>\u307e\u305a\u306f\u5b50\u30c6\u30fc\u30de\u3092<code>wordpress<\/code>\u306b\u8a8d\u8b58\u3055\u305b\u308b\u305f\u3081\u306b<code>style.css<\/code>\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a18\u8ff0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>\/wp-content\/themes\/twentytwentyfour-with-summary\/style.css<\/strong><\/p>\n<pre><strong>\/*\r\nTheme Name:   Twenty Twenty-Four with Summary\r\nTheme URI:    https:\/\/wordpress.org\/themes\/twentytwentyfour\/\r\nDescription:  Twenty Twenty-Four with Summary\r\nAuthor:       Sukohi Kuhoh\r\nAuthor URI:   http:\/\/example.com\r\nTemplate:     twentytwentyfour\r\nVersion:      1.0.0\r\nLicense:      GNU General Public License v2 or later\r\nLicense URI:  http:\/\/www.gnu.org\/licenses\/gpl-2.0.html\r\nTags: one-column, custom-colors, custom-menu, custom-logo, editor-style, featured-images, full-site-editing, block-patterns, rtl-language-support, sticky-post, threaded-comments, translation-ready, wide-blocks, block-styles, style-variations, accessibility-ready, blog, portfolio, news\r\n*\/\r\n<\/strong><\/pre>\n<p><code>style.css<\/code>\u304c\u4fdd\u5b58\u3067\u304d\u305f\u3089\u3001\u3082\u3046<code>wordpress<\/code>\u306f\u3053\u306e\u5b50\u30c6\u30fc\u30de\u3092\u8a8d\u8b58\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u30da\u30fc\u30b8\u5de6\u5074\u30e1\u30cb\u30e5\u30fc\u304b\u3089\u300c<strong>\u5916\u89b3 \uff1e \u30c6\u30fc\u30de<\/strong>\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12311\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_4.png\" alt=\"\" width=\"340\" height=\"101\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_4.png 340w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_4-300x89.png 300w\" sizes=\"auto, (max-width: 340px) 100vw, 340px\" \/><\/p>\n<p>\uff08\u3061\u3087\u3063\u3068\u308f\u304b\u308a\u306b\u304f\u3044\u3067\u3059\u304c\uff09\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u65b0\u3057\u3044\u30c6\u30fc\u30de\u3068\u3057\u3066\u300c<strong>\u5b50\u30c6\u30fc\u30de<\/strong>\u300d\u304c\u9078\u629e\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12310\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_3.png\" alt=\"\" width=\"640\" height=\"348\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_3.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_3-300x163.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u3067\u306f\u3001\u30de\u30a6\u30b9\u3092\u5408\u308f\u305b\u3066\u300c<strong>\u6709\u52b9\u5316<\/strong>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12315\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_5.png\" alt=\"\" width=\"468\" height=\"369\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_5.png 468w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_5-300x237.png 300w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/p>\n<p>\u3053\u308c\u3067\u3001\u6539\u9020\u3055\u308c\u305f\u300c<strong>Twenty Twenty-Four with Summary<\/strong>\u300d\u304c<code>wordpress<\/code>\u306b\u9069\u7528\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4fbf\u5229\u3067\u3059\u306d\ud83d\ude04\u2728<\/p>\n<h1>functions.php \u3092\u3064\u304f\u308b<\/h1>\n<p>\u6b21\u306b\u4eca\u56de\u306e\u30e1\u30a4\u30f3\u306b\u306a\u308b\u300c<strong>\u4e09\u884c\u8981\u7d04<\/strong>\u300d\u3092\u3064\u304f\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p><strong>\/wp-content\/themes\/twentytwentyfour-with-summary\/functions.php<\/strong><\/p>\n<div>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>define('OPEN_AI_ACCESS_TOKEN', '\uff08\u3053\u3053\u306b\u3042\u306a\u305f\u306e\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\uff09'); \/\/ OpenAI \u306e\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3<\/strong>\r\n<strong>define('CHATGPT_SUMMARY_TEXT_LENGTH', 1000); \/\/ ChatGPT \u306b\u9001\u4fe1\u3059\u308b\u6587\u5b57\u6570<\/strong>\r\n\r\n<strong>\/\/ ChatGPT API \u3067\u8981\u7d04\u3092\u53d6\u5f97\u3059\u308b<\/strong>\r\n<strong>function get_summary_texts_from_chatgpt_api() {<\/strong>\r\n\r\n<strong>    $post_id = get_the_ID();<\/strong>\r\n<strong>    $cache_path = get_chatgpt_cache_file_path($post_id);<\/strong>\r\n<strong>    $summary_json = '';<\/strong>\r\n\r\n<strong>    if(file_exists($cache_path)) { \/\/ \u3059\u3067\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u3042\u308b\u5834\u5408<\/strong>\r\n\r\n<strong>        $summary_json = file_get_contents($cache_path);<\/strong>\r\n\r\n<strong>    } else {<\/strong>\r\n\r\n<strong>        $contents = get_the_content();<\/strong>\r\n<strong>        $contents = wp_strip_all_tags($contents);<\/strong>\r\n<strong>        $contents = str_replace([\"\\n\", \"\\r\", \"\\t\"], '', $contents);<\/strong>\r\n<strong>        $full_prompt_text = \"\u6b21\u306e\u6587\u7ae0\u3092\uff11\u884c30\u6587\u5b57\u4ee5\u5185\u306e\uff13\u884c\u3067\u8981\u7d04\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u8981\u7d04\u4ee5\u5916\u306e\u8aac\u660e\u306f\u4e00\u5207\u4e0d\u8981\u3067\u3059\u3002\u306a\u304a\u8981\u7d04\u306fJSON\u5f62\u5f0f\u306e\u914d\u5217\u3067\u8fd4\u3057\u3066\u304f\u3060\u3055\u3044\u3002\\n#\u6587\u7ae0\\n\". $contents;<\/strong>\r\n<strong>        $prompt_text = mb_substr($full_prompt_text, 0, CHATGPT_SUMMARY_TEXT_LENGTH); \/\/ \u8a18\u4e8b\u3092\u9001\u4fe1\u3067\u304d\u308b\u6587\u5b57\u6570\u306b\u3059\u308b<\/strong>\r\n\r\n<strong>        $ch = curl_init();<\/strong>\r\n<strong>        curl_setopt($ch, CURLOPT_URL, 'https:\/\/api.openai.com\/v1\/chat\/completions');<\/strong>\r\n<strong>        curl_setopt($ch, CURLOPT_HTTPHEADER, [<\/strong>\r\n<strong>            'Content-Type: application\/json',<\/strong>\r\n<strong>            'Authorization: Bearer '. OPEN_AI_ACCESS_TOKEN,<\/strong>\r\n<strong>        ]);<\/strong>\r\n<strong>        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<\/strong>\r\n<strong>        curl_setopt($ch, CURLOPT_POST, true);<\/strong>\r\n<strong>        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([<\/strong>\r\n<strong>            'model' =&gt; 'gpt-3.5-turbo',<\/strong>\r\n<strong>            'messages' =&gt; [<\/strong>\r\n<strong>                ['role' =&gt; 'user', 'content' =&gt; $prompt_text]<\/strong>\r\n<strong>            ]<\/strong>\r\n<strong>        ]));<\/strong>\r\n<strong>        $response_body = curl_exec($ch);<\/strong>\r\n<strong>        curl_close($ch);<\/strong>\r\n\r\n<strong>        try {<\/strong>\r\n\r\n<strong>            $summary_data = json_decode($response_body, true);<\/strong>\r\n<strong>            $summary_json = $summary_data['choices'][0]['message']['content'];<\/strong>\r\n\r\n<strong>        } catch(\\Exception) {}<\/strong>\r\n\r\n<strong>        file_put_contents($cache_path, $summary_json);<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>    try {<\/strong>\r\n\r\n<strong>        return json_decode($summary_json, true);<\/strong>\r\n\r\n<strong>    } catch(\\Exception) {}<\/strong>\r\n\r\n<strong>    return [];<\/strong>\r\n<strong>}<\/strong>\r\n\r\n<strong>\/\/ \u8981\u7d04\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u30d5\u30a1\u30a4\u30eb\u540d<\/strong>\r\n<strong>function get_chatgpt_cache_file_path($post_id) {<\/strong>\r\n\r\n<strong>    $filename = 'chatgpt_summary_'. $post_id .'.json';<\/strong>\r\n\r\n<strong>    return WP_CONTENT_DIR .'\/chatgpt_summaries\/'. $filename;<\/strong>\r\n\r\n<strong>}<\/strong>\r\n\r\n<strong>\/\/ \u8a18\u4e8b\u306b\u8981\u7d04\u3092\u8ffd\u52a0\u3059\u308b<\/strong>\r\n<strong>function add_custom_content_before_post($content) {<\/strong>\r\n\r\n<strong>    if (is_single()) { \/\/ \u500b\u5225\u8a18\u4e8b\u306e\u5834\u5408\u306e\u307f\u8981\u7d04\u3092\u5148\u982d\u306b\u3064\u3051\u308b<\/strong>\r\n\r\n<strong>        $summary_texts = get_summary_texts_from_chatgpt_api();<\/strong>\r\n<strong>        $summary_texts_count = count($summary_texts);<\/strong>\r\n\r\n<strong>        if($summary_texts_count &gt; 0) {<\/strong>\r\n\r\n<strong>            $summary_content = '&lt;p&gt;\u3010\u4e09\u884c\u8981\u7d04\u3011&lt;div style=\"border:1px solid #999;padding:15px;\"&gt;';<\/strong>\r\n\r\n<strong>            for($i = 0 ; $i &lt; $summary_texts_count ; $i++) {<\/strong>\r\n\r\n<strong>                $summary_content .= '\u30fb'. $summary_texts[$i] .'&lt;br&gt;';<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>            $summary_content .= '&lt;\/div&gt;&lt;\/p&gt;';<\/strong>\r\n<strong>            $content = $summary_content . $content;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>    return $content;<\/strong>\r\n\r\n<strong>}<\/strong>\r\n\r\n<strong>\/\/ \u8a18\u4e8b\u3092\u66f4\u65b0\u3057\u305f\u969b\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u524a\u9664\u3059\u308b<\/strong>\r\n<strong>function on_post_update($post_id, $post_after, $post_before) {<\/strong>\r\n\r\n<strong>    $cache_path = get_chatgpt_cache_file_path($post_id);<\/strong>\r\n\r\n<strong>    if(file_exists($cache_path)) { \/\/ \u3059\u3067\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u3042\u308b\u5834\u5408\u306f\u524a\u9664<\/strong>\r\n\r\n<strong>        @unlink($cache_path);<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>}<\/strong>\r\n\r\n<strong>\/\/ \u30a2\u30af\u30b7\u30e7\u30f3\u30d5\u30c3\u30af<\/strong>\r\n<strong>add_filter('the_content', 'add_custom_content_before_post');<\/strong>\r\n<strong>add_action('post_updated', 'on_post_update', 10, 3);<\/strong><\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u304a\u304a\u307e\u304b\u306b\u3084\u3063\u3066\u3044\u308b\u3053\u3068\u306f\u4ee5\u4e0b\uff12\u70b9\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u8a18\u4e8b\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u3055\u308c\u305f\u3089\u3001ChatGPT API \u3067\u4e09\u884c\u8981\u7d04\u3092\u53d6\u5f97\uff06\u8868\u793a\u3059\u308b\uff08\u305f\u3060\u3057\u3001\u4f55\u56de\u3082\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u304a\u91d1\u304c\u304b\u304b\u308b\u306e\u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u52b9\u304f\u3088\u3046\u306b\u3059\u308b\uff09<\/li>\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u6c38\u9060\u306b\u6b8b\u308b\u306e\u306f\u554f\u984c\u306a\u306e\u3067\u3001\u8a18\u4e8b\u304c\u66f4\u65b0\u3055\u308c\u305f\u3089\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u6d88\u3059<\/li>\n<\/ul>\n<p>\u306a\u304a\u3001<code>OPEN_AI_ACCESS_TOKEN<\/code>\u306f\u3042\u306a\u305f\u306e\u30c8\u30fc\u30af\u30f3\uff08API\u30ad\u30fc\uff09\u3092\u30bb\u30c3\u30c8\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305f\u3001<code>CHATGPT_SUMMARY_TEXT_LENGTH<\/code>\u306f<code>ChatGPT API<\/code>\u306b\u9001\u4fe1\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u306e\u9577\u3055\u3067\u3059\u3002<\/p>\n<p>\u5f53\u521d\u306f\u3001<code>URL<\/code>\u3092\u9001\u4fe1\u3057\u3066\u300c<strong>Web\u30d6\u30e9\u30a6\u30b8\u30f3\u30b0\u6a5f\u80fd<\/strong>\u300d\u3092\u4f7f\u3044\u3001\u8a72\u5f53\u3059\u308b\u8a18\u4e8b\u306e\u30c6\u30ad\u30b9\u30c8\u3092\u53d6\u5f97\u3057\u3088\u3046\u3068\u8003\u3048\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u6b8b\u5ff5\u306a\u3053\u3068\u306b<code>API<\/code>\u3067\u306f\u30d6\u30e9\u30a6\u30b8\u30f3\u30b0\u6a5f\u80fd\u304c\u4f7f\u3048\u306a\u3044\u3088\u3046\u3060\u3063\u305f\u306e\u3067\u3001\u76f4\u63a5\u30c6\u30ad\u30b9\u30c8\u3092\u6e21\u3059\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u305d\u3046\u306a\u308b\u3068\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u6587\u5b57\u6570\u5236\u9650\u304c\u3042\u308b\u306e\u3067\u3001\u30c8\u30fc\u30bf\u30eb\u30671,000\u6587\u5b57\u306b\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u3042\u3068\u30011,000\u6587\u5b57\u4ee5\u964d\u306f\u305d\u308c\u307b\u3069\u8981\u7d04\u306b\u306f\u5f71\u97ff\u306f\u5c11\u306a\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u306e\u8003\u3048\u3082\u3042\u308a\u307e\u3059\uff09<\/p>\n<\/div>\n<h1>\u30d5\u30a9\u30eb\u30c0\u3092\u3064\u304f\u308b<\/h1>\n<p>\u5148\u307b\u3069\u306e<code>functions.php<\/code>\u306e\u4e2d\u3067\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u304c\u307e\u3060\u5b58\u5728\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3001<code>wp-contents<\/code>\u306e\u4e2d\u306b<code>chatgpt_summaries<\/code>\u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u3092\u3064\u304f\u3063\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\/wp-contents\/chatgpt_summaries<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12314\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_6.png\" alt=\"\" width=\"512\" height=\"192\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_6.png 512w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_6-300x113.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<p>\u203b \u306a\u304a\u3001\u3053\u306e\u30d5\u30a9\u30eb\u30c0\u306b\u66f8\u304d\u8fbc\u307f\u6a29\u9650\u304c\u306a\u3044\u3068\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3067\u304d\u306a\u3044\u306e\u3067<code>chmod 777<\/code>\u306a\u3069\u3067\u6a29\u9650\u3092\u4e0e\u3048\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u308c\u3067\u4f5c\u696d\u306f\u5b8c\u4e86\u3067\u3059\u3002<br \/>\n\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\u2757<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u306f\u4f55\u3067\u3082\u3044\u3044\u306e\u3067\u8a18\u4e8b\u3092\u6295\u7a3f\u3057\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u904e\u53bb\u7b2c\uff12\u56de\u76ee\u306e\u79c1\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\uff08\uff11\u56de\u76ee\u306f\u3042\u307e\u308a\u306b\u3082\u77ed\u304b\u304b\u3063\u305f\u306e\u3067\ud83d\ude05\uff09<\/p>\n<p>\u3067\u306f\u3001\u8a72\u5f53\u3059\u308b\u30da\u30fc\u30b8\u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3069\u3046\u306a\u308b\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12318\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_7.png\" alt=\"\" width=\"640\" height=\"661\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_7.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/01\/wordpress_chatgpt_summary_7-290x300.png 290w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u4e09\u884c\u8981\u7d04\u304c\u8868\u793a\u3055\u308c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\u76f8\u5909\u308f\u3089\u305a\u5927\u597d\u304d\u306a Laravel \u3067\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u958b\u767a<\/li>\n<li>\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u30a8\u30e9\u30fc\u3092\u8abf\u67fb<\/li>\n<li>\u554f\u984c\u7b87\u6240\u306f\u4e0d\u660e<\/li>\n<\/ul>\n<p>\u304d\u3061\u3093\u3068\u8981\u7d04\u3067\u304d\u3066\u3044\u307e\u3059\u3002\uff08\u3061\u306a\u307f\u306b\u4eca\u56de\u306f<code>gpt-3.5-turbo<\/code>\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3001<code>gpt-4<\/code>\u3092\u4f7f\u3048\u3070\u3082\u3063\u3068\u7cbe\u5ea6\u304c\u3042\u304c\u308b\u3067\u3057\u3087\u3046\uff09<\/p>\n<p>\u6210\u529f\u3067\u3059\ud83d\ude04\u2728<\/p>\n<h1>\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h1>\n<p>\u4eca\u56de\u306e\u3088\u3046\u306b<code>ChatGPT API<\/code>\u3092\u4f7f\u3048\u3070\u3001\u3053\u308c\u307e\u3067\u4eba\u304c\u6642\u9593\u3092\u304b\u3051\u3066\u3044\u305f\u8981\u7d04\u3092\u81ea\u52d5\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f<code>wordpress<\/code>\u306b\u9650\u3089\u305a\u3001\u306a\u3093\u306a\u3089<code>PHP<\/code>\u4ee5\u5916\u3067\u3082\u5b9f\u884c\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u3082\u3057\u696d\u52d9\u306e\u52b9\u7387\u5316\u306e\u305f\u3081\u306b<code>ChatGPT API<\/code>\u3092\u4f7f\u3063\u3066\u307f\u305f\u3044\u65b9\u306f\u305c\u3072\u304a\u554f\u3044\u5408\u308f\u305b\u304b\u3089\u3054\u76f8\u8ac7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059 \ud83d\ude04\u2728<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u4e45\u3057\u3076\u308a\u306b<code>wordpress<\/code>\u306e\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u30d6\u30ed\u30b0\u3082<code>wordpress<\/code>\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u6bce\u9031\u89e6\u3063\u3066\u306f\u3044\u308b\u3082\u306e\u306e\u3001\u6539\u9020\u306f\u4e45\u3057\u3076\u308a\u3060\u3063\u305f\u306e\u3067\u65b0\u9bae\u306a\u6c17\u5206\u3067\u4f5c\u696d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001<code>wordpress<\/code>\u306f<code>PHP8.0<\/code>\u4ee5\u4e0a\u306f\uff08\u30d9\u30fc\u30bf\u30b5\u30dd\u30fc\u30c8\uff09\u3068\u3044\u3046\u3053\u3068\u3067\u672c\u683c\u30b5\u30dd\u30fc\u30c8\u304c\u307e\u3060\u306e\u3088\u3046\u3067\u3059\u306d\u3002<\/p>\n<p>\u6b63\u76f4\u306a\u3068\u3053\u308d\u3001<code>PHP 8.0<\/code>\u4ee5\u4e0a\u306f\u30b9\u30bf\u30f3\u30c0\u30fc\u30c9\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u601d\u3046\u306e\u3067\u65e9\u304f\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u304f\u308c\u305f\u3089\u306a\u3068\u3044\u3046\u30ab\u30f3\u30b8\u3067\u3057\u305f\u3002\uff08\u3044\u308d\u3044\u308d\u3068\u5f8c\u65b9\u4e92\u63db\u3092\u8003\u3048\u308b\u3068\u96e3\u3057\u3044\u306e\u3067\u3057\u3087\u3046\u304b\ud83e\udd14\uff09<\/p>\n<p>\u203b \u4eca\u56de\u306f\u30c6\u30b9\u30c8\u306a\u306e\u3067\u6c17\u306b\u305b\u305a<code>PHP 8.2<\/code>\u3067\u3084\u3063\u3066\u307f\u307e\u3057\u305f\uff08\u7b11\uff09<\/p>\n<p>\u305c\u3072\u307f\u306a\u3055\u3093\u3082\u3044\u308d\u3044\u308d\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9470 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13.png\" alt=\"\" width=\"294\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13.png 294w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13-276x300.png 276w\" sizes=\"auto, (max-width: 294px) 100vw, 294px\" \/>\u300c\u5e74\u672b\u98df\u3063\u305f\u3082\u306e\u306eMVP\u306f\u3001<br \/>\n\u30a8\u30d3\u5473\u564c\u306e\u304a\u5bff\u53f8\u3067\u3057\u305f\u3002<br \/>\n\u30ac\u30c1\u3067\u3046\u307e\u304b\u3063\u305f\u2757\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u6700\u8fd1\u306f\u30db\u30f3\u30c8\u306b\u5909\u5316\u306e\u65e9\u3044\u6642\u4ee3\u3067\u3059\u304b\u3089\u60c5\u5831\u53ce\u96c6\u304c\u304b\u304b\u305b\u306a\u3044\u306e\u3067\u3001\u3067\u304d\u308b\u3060\u3051\u304d\u3061\u3093\u3068\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u3093\u306a\u300c\u60c5\u5831\u904e\u591a\u300d\u306b\u306a\u308a\u304c\u3061\u306a\u6211\u3005 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=12307\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;wordpress \u306b ChatGPT \u3067\u3064\u304f\u3063\u305f\u300c\u4e09\u884c\u8981\u7d04\u300d\u3092\u8868\u793a\u3059\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":12321,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[],"class_list":["post-12307","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/12307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12307"}],"version-history":[{"count":4,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/12307\/revisions"}],"predecessor-version":[{"id":12320,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/12307\/revisions\/12320"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/12321"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}