{"id":2584,"date":"2013-10-04T15:37:49","date_gmt":"2013-10-04T06:37:49","guid":{"rendered":"http:\/\/apr20.net\/?p=2584"},"modified":"2013-10-04T15:37:49","modified_gmt":"2013-10-04T06:37:49","slug":"wordpress%e3%81%ae%e6%8a%95%e7%a8%bf%e6%97%a5%e3%81%8b%e3%82%89%e3%81%ae%e7%b5%8c%e9%81%8e%e6%97%a5%e6%95%b0%e3%82%92%e8%aa%bf%e3%81%b9%e3%82%8b%ef%bc%882%e3%81%a4%e3%81%ae%e6%97%a5%e4%bb%98%e3%81%ae","status":"publish","type":"post","link":"https:\/\/apr20.net\/?p=2584","title":{"rendered":"WordPress\u306e\u6295\u7a3f\u65e5\u304b\u3089\u306e\u7d4c\u904e\u65e5\u6570\u3092\u8abf\u3079\u308b\uff082\u3064\u306e\u65e5\u4ed8\u306e\u5dee\u5206\uff09"},"content":{"rendered":"<p>\u30d6\u30ed\u30b0\u306e\u8a18\u4e8b\u304c\u53e4\u3044\u5834\u5408\u306b\u300c\u3053\u306e\u8a18\u4e8b\u306f\u53e4\u3044\u304b\u3089\u6ce8\u610f\u3057\u3066\u306d\u301c\u300d\u307f\u305f\u3044\u306a\u304a\u77e5\u3089\u305b\u304c\u8868\u793a\u3055\u308c\u308b\u30b5\u30a4\u30c8\u3092\u305f\u307e\u306b\u898b\u304b\u3051\u307e\u305b\u3093\u304b\uff1f<\/p>\n<p>\u3053\u306e\u30b5\u30a4\u30c8\u3082\u8cde\u5473\u671f\u9650\u5207\u308c\u306e\u8a18\u4e8b\u304c\u3042\u308a\u305d\u3046\u306a\u6c17\u914d\u304c\u30e0\u30f3\u30e0\u30f3\u3057\u3066\u304d\u305f\u306e\u3067\u3001\u534a\u5e74\u4ee5\u4e0a\u524d\u306e\u8a18\u4e8b\u306f\u53e4\u304f\u306a\u3063\u3066\u307e\u3059\u3088\u301c\u3063\u3066\u8868\u793a\u3057\u3088\u3046\u3068\u601d\u3044\u3001\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u3002\n<\/p>\n<h3>\u5b9f\u88c5\u3057\u305f\u30b3\u30fc\u30c9<\/h3>\n<p>[php]&lt;?php<\/p>\n<p>function day_diff($date1, $date2) {<\/p>\n<p>    \/\/ \u65e5\u4ed8\u3092UNIX\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u306b\u5909\u63db<br \/>\n    $timestamp1 = strtotime($date1);<br \/>\n    $timestamp2 = strtotime($date2);<\/p>\n<p>    \/\/ \u4f55\u79d2\u96e2\u308c\u3066\u3044\u308b\u304b\u3092\u8a08\u7b97<br \/>\n    $seconddiff = abs($timestamp2 &#8211; $timestamp1);<\/p>\n<p>    \/\/ \u65e5\u6570\u306b\u5909\u63db<br \/>\n    $daydiff = $seconddiff \/ (60 * 60 * 24);<\/p>\n<p>    \/\/ \u623b\u308a\u5024<br \/>\n    return $daydiff;<\/p>\n<p>}<\/p>\n<p>\/\/\u672c\u65e5\u306e\u65e5\u4ed8\u3092\u53d6\u5f97<br \/>\n$today = date(&quot;Y-m-d&quot;);<\/p>\n<p>\/\/\u8868\u793a\u4e2d\u306e\u8a18\u4e8b\u306e\u6295\u7a3f\u65e5\u53d6\u5f97<br \/>\n$posted = get_the_date(&#8216;Y-m-d&#8217;);<\/p>\n<p>\/\/ \u65e5\u4ed8\u3092\u95a2\u6570\u306b\u6e21\u3059<br \/>\n$day = day_diff($today, $posted);<\/p>\n<p>?&gt;[\/php]<\/p>\n<p>\u30b3\u30fc\u30c9\u5185\u306b\u8aac\u660e\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u7279\u306b\u89e3\u8aac\u3059\u308b\u5fc5\u8981\u3082\u306a\u3044\u304b\u3082\u3067\u3059\u304c\u3001\u4e00\u5fdc\u3001\u8aac\u660e\u3059\u308b\u3068\u3001day_diff\u95a2\u6570\u306f\u30012\u3064\u306e\u65e5\u4ed8\u3092\u6bd4\u8f03\u3057\u3066\u3001\u65e5\u6570\u306e\u5dee\u3092\u8fd4\u3057\u307e\u3059\u3002\u53c2\u8003\u30b5\u30a4\u30c8\u69d8\u304b\u3089\u3001\u305d\u306e\u307e\u307e\u62dd\u501f\u3057\u3066\u3044\u307e\u3059\u3002(\u30fb\u30fb;)<\/p>\n<p>date\u95a2\u6570\u3068\u3001WordPress\u306eget_the_date\u95a2\u6570\u306f\u3001\u672c\u65e5\u306e\u65e5\u4ed8\u3001\u8a18\u4e8b\u306e\u6295\u7a3f\u65e5\u3092\u305d\u308c\u305e\u308c\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>2\u3064\u306e\u65e5\u4ed8\u3092\u5148\u307b\u3069\u306eday_diff\u95a2\u6570\u306b\u6e21\u3057\u307e\u3059\u3002$day\u306b\u306f\u3001\u7d4c\u904e\u65e5\u6570\u304c\u5165\u308a\u307e\u3059\u3002<\/p>\n<p>[php]$day = day_diff($today, $posted);[\/php]<\/p>\n<p>\u3042\u3068\u306f\u3001$day\u3092\u304a\u597d\u307f\u306b\u5224\u5225\u3057\u3066\u3001\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u5f53\u30b5\u30a4\u30c8\u3067\u306f\u3001$day\u304c180\u3092\u8d85\u3048\u3066\u305f\u3089\u3001\u5927\u4f53\u534a\u5e74\u306f\u904e\u304e\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4ee5\u4e0b\u307f\u305f\u3044\u306a\u611f\u3058\u3067\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>[php]&lt;?php<br \/>\n\/\/180\u65e5\u3092\u904e\u304e\u3066\u3044\u308b\u5834\u5408<br \/>\nif($day &gt; 180){ ?&gt;<br \/>\n&lt;p&gt;\u95b2\u89a7\u4e2d\u306e\u8a18\u4e8b\u306f\u534a\u5e74\u4ee5\u4e0a\u524d\u306e\u8a18\u4e8b\u3067\u3059\u306e\u3067\u3001\u5185\u5bb9\u304c\u53e4\u304f\u306a\u3063\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3088\u301c\u3002&lt;\/p&gt;<br \/>\n&lt;?php } ?&gt;[\/php]<\/p>\n<p>\u53c2\u8003\u30b5\u30a4\u30c8\uff1a<a href=\"http:\/\/raining.bear-life.com\/php\/\u6307\u5b9a\u3057\u305f\u4e8c\u3064\u306e\u65e5\u4ed8\u306e\u5dee\u3092\u8abf\u3079\u308b\u65b9\u6cd5\" target=\"_blank\">http:\/\/raining.bear-life.com\/php\/\u6307\u5b9a\u3057\u305f\u4e8c\u3064\u306e\u65e5\u4ed8\u306e\u5dee\u3092\u8abf\u3079\u308b\u65b9\u6cd5<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30d6\u30ed\u30b0\u306e\u8a18\u4e8b\u304c\u53e4\u3044\u5834\u5408\u306b\u300c\u3053\u306e\u8a18\u4e8b\u306f\u53e4\u3044\u304b\u3089\u6ce8\u610f\u3057\u3066\u306d\u301c\u300d\u307f\u305f\u3044\u306a\u304a\u77e5\u3089\u305b\u304c\u8868\u793a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2593,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,5],"tags":[],"class_list":["post-2584","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-wordpress-web-category"],"_links":{"self":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/2584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2584"}],"version-history":[{"count":0,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/2584\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/"}],"wp:attachment":[{"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}