{"id":1309,"date":"2018-06-07T19:07:46","date_gmt":"2018-06-07T10:07:46","guid":{"rendered":"http:\/\/4koma-web.com\/coding\/?p=1309"},"modified":"2018-06-07T19:07:46","modified_gmt":"2018-06-07T10:07:46","slug":"wordpress%e3%81%a7rss%e3%83%95%e3%82%a3%e3%83%bc%e3%83%89%e3%82%92%e5%8f%96%e5%be%97%e3%81%97%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/4koma-web.com\/coding\/wordpress%e3%81%a7rss%e3%83%95%e3%82%a3%e3%83%bc%e3%83%89%e3%82%92%e5%8f%96%e5%be%97%e3%81%97%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/","title":{"rendered":"wordpress\u3067RSS\u30d5\u30a3\u30fc\u30c9\u3092\u53d6\u5f97\u3057\u3066\u8868\u793a\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u30ef\u30fc\u30c9\u30d7\u30ec\u30b9\u3067\u6295\u7a3f\u3057\u305f\u8a18\u4e8b\u3092\u3001\u4ed6\u306e\u30b5\u30a4\u30c8\u3067\u8868\u793a\u3057\u305f\u3044\u306a\u3093\u3066\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3001\u30ef\u30fc\u30c9\u30d7\u30ec\u30b9\u306eRSS\u3092\u53d6\u5f97\u3057\u3066\u8868\u793a\u3055\u305b\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>RSS\u306f\u30b5\u30a4\u30c8\u306e\u30e1\u30bf\u30c7\u30fc\u30bf\u3092XML\u30d9\u30fc\u30b9\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3067\u69cb\u9020\u5316\u3057\u3066\u8a18\u8ff0\u3059\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u4e3b\u306b\u66f4\u65b0\u60c5\u5831\u3092\u516c\u958b\u3059\u308b\u5834\u5408\u306b\u4f7f\u7528\u3055\u308c\u3001\u30bf\u30a4\u30c8\u30eb\u3084URL\u3084\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u3001\u516c\u958b\u65e5\u6642\u306a\u3069\u306e\u5404\u7a2e\u60c5\u5831\u3092\u8a18\u8ff0\u3067\u304d\u307e\u3059<br \/>\n\u3053\u306e\u60c5\u5831\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3001\u66f4\u65b0\u60c5\u5831\u306a\u3069\u3092\u7fd2\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\r\n<?php\r\nfunction show_rss() {\r\n\tinclude_once( ABSPATH . WPINC . '\/feed.php' );\r\n\r\n\r\n\t$url = '\u53d6\u5f97\u3059\u308b\u30b5\u30a4\u30c8\u306e\u30d5\u30a3\u30fc\u30c9';\r\n\t$rss = fetch_feed( $url );\r\n\r\n\tremove_filter( 'wp_feed_cache_transient_lifetime' , 'return_1hour' );\r\n\t$maxitems = 0;\r\n\r\n\tif ( !is_wp_error( $rss ) ) {\r\n\t\t\/\/ \u30d5\u30a3\u30fc\u30c9\u3092\u62fe\u5f97\u3059\u308b\u4ef6\u6570\r\n\t\t$maxitems = $rss->get_item_quantity( 5 );\r\n\t\t$rss_items = $rss->get_items( 0, $maxitems );\r\n\t}\r\n\r\n\techo '<ul>';\r\n\tif ( $maxitems == 0 ) {\r\n\t\techo '<li>No items<\/li>';\r\n\t}\r\n\telse {\r\n\t\tforeach ( $rss_items as $item ) {\r\n\t\t\techo '<li><a href=\"' . esc_url( $item->get_permalink() ) . '\">';\r\n\t\t\techo '<h2>' . esc_html( $item->get_title() ) . '<\/h2>';\r\n\t\t\t\r\n\t\t\tif ( preg_match_all( '\/src=\"([^\"]*)\"\/', $item->get_content(), $image ) ) {\r\n\t\t\t\tif ($image[1]) {\r\n\t\t\t\t\techo '<img decoding=\"async\" src=\"' . esc_url( $image[1][0] ) . '\" alt=\"no title\"\/>';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\techo '<\/a>';\r\n\t\t\t\/\/ \u6295\u7a3f\u3057\u305f\u65e5\u6642\u3092\u8868\u793a\r\n\t\t\techo $item->get_date( 'Y-m-d H:i:s' );\r\n\r\n\t\t\t\/\/ \u30ab\u30c6\u30b4\u30ea\u30fc\u3092\u8868\u793a\r\n\t\t\t$categorys = $item->get_categories();\r\n\t\t\tforeach ( $categorys as $category ) {\r\n\t\t\t\techo esc_html( $category->get_label() );\r\n\t\t\t}\r\n\t\t\techo '<\/li>';\r\n\t\t}\r\n\t}\r\n\techo '<\/ul>';\r\n}\r\n\r\nfunction return_1hour( $seconds ) {\r\n\treturn 3600;\r\n}\r\n\r\n?>\r\n<\/pre>\n<pre>\r\n$url = '\u53d6\u5f97\u3059\u308b\u30b5\u30a4\u30c8\u306e\u30d5\u30a3\u30fc\u30c9';\r\n\t$rss = fetch_feed( $url );\r\n<\/pre>\n<p>\u3053\u3053\u3067\u53d6\u5f97\u3057\u305f\u3044RSS\u306eURL\u3092\u8a2d\u5b9a\u3059\u308c\u3070\u62fe\u5f97\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30ef\u30fc\u30c9\u30d7\u30ec\u30b9\u3067\u6295\u7a3f\u3057\u305f\u8a18\u4e8b\u3092\u3001\u4ed6\u306e\u30b5\u30a4\u30c8\u3067\u8868\u793a\u3057\u305f\u3044\u306a\u3093\u3066\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002 \u4eca\u56de\u306f\u3001\u30ef\u30fc\u30c9\u30d7\u30ec\u30b9\u306eRSS\u3092\u53d6\u5f97\u3057\u3066\u8868\u793a\u3055\u305b\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 RSS\u306f\u30b5\u30a4\u30c8\u306e\u30e1\u30bf\u30c7\u30fc\u30bf\u3092XML\u30d9\u30fc\u30b9\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3067\u69cb\u9020\u5316\u3057\u3066\u8a18\u8ff0\u3059\u308b\u3082 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"","_original_post":"","footnotes":""},"categories":[1],"tags":[],"publishpress_future_action":{"enabled":false,"date":"2026-04-11 18:32:17","action":"change-status","newStatus":"draft","terms":[],"taxonomy":"category"},"_links":{"self":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/posts\/1309"}],"collection":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/comments?post=1309"}],"version-history":[{"count":0,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/posts\/1309\/revisions"}],"wp:attachment":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/media?parent=1309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/categories?post=1309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/tags?post=1309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}