{"id":196210,"date":"2015-08-26T17:11:08","date_gmt":"2015-08-26T08:11:08","guid":{"rendered":"https:\/\/ja.wordpress.org\/support\/2015\/08\/26\/%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aa%e3%81%97%e3%81%a7%e3%81%ae%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e3%81%ae%e8%a1%a8%e7%a4%ba%e6%96%b9%e6%b3%95\/"},"modified":"2016-09-15T22:05:23","modified_gmt":"2016-09-15T13:05:23","slug":"%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aa%e3%81%97%e3%81%a7%e3%81%ae%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e3%81%ae%e8%a1%a8%e7%a4%ba%e6%96%b9%e6%b3%95","status":"closed","type":"topic","link":"https:\/\/ja.wordpress.org\/support\/topic\/%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aa%e3%81%97%e3%81%a7%e3%81%ae%e4%ba%ba%e6%b0%97%e8%a8%98%e4%ba%8b%e3%81%ae%e8%a1%a8%e7%a4%ba%e6%96%b9%e6%b3%95\/","title":{"rendered":"\u30d7\u30e9\u30b0\u30a4\u30f3\u306a\u3057\u3067\u306e\u4eba\u6c17\u8a18\u4e8b\u306e\u8868\u793a\u65b9\u6cd5"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002<br \/>\n\u73fe\u5728\u3001\u30d6\u30ed\u30b0\u3092\u69cb\u7bc9\u3057\u3066\u304a\u308a\u3001\u305d\u306e\u969b\u306b\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u306a\u3057\u3067\u95b2\u89a7\u6570\u306e\u9806\u3067\u4eba\u6c17\u8a18\u4e8b\u3092<br \/>\n\u8868\u793a\u3055\u305b\u305f\u3044\u3068\u601d\u3044\u3001<br \/>\n\u4e0b\u8a18\u3092functions.php\u306b<\/p>\n<blockquote>\n<p>\/\/\u30a2\u30af\u30bb\u30b9\u6570\u306e\u53d6\u5f97<br \/>\nfunction get_post_views( $postID ) {<br \/>\n    $count_key = &#8216;post_views_count&#8217;;<br \/>\n    $count     = get_post_meta( $postID, $count_key, true );<br \/>\n    if ( $count == &#8221; ) {<br \/>\n        delete_post_meta( $postID, $count_key );<\/p>\n<p>        add_post_meta( $postID, $count_key, &#8216;0&#8217; );<\/p>\n<p>        return &#8220;0 views&#8221;;<br \/>\n    }<\/p>\n<p>    return $count . &#8221;;<br \/>\n}<\/p>\n<p>\/\/\u30a2\u30af\u30bb\u30b9\u6570\u306e\u4fdd\u5b58<br \/>\nfunction set_post_views( $postID ) {<br \/>\n    $count_key = &#8216;post_views_count&#8217;;<br \/>\n    $count     = get_post_meta( $postID, $count_key, true );<br \/>\n    if ( $count == &#8221; ) {<br \/>\n        $count = 0;<br \/>\n        delete_post_meta( $postID, $count_key );<br \/>\n        add_post_meta( $postID, $count_key, &#8216;0&#8217; );<br \/>\n    } else {<br \/>\n        $count ++;<br \/>\n        update_post_meta( $postID, $count_key, $count );<br \/>\n    }<br \/>\n}<\/p>\n<\/blockquote>\n<p>single.php\u306b\u3001<\/p>\n<blockquote>\n<p>&lt;?php<br \/>\n$args = array(<br \/>\n    &#8216;post_type&#8217;     =&gt; &#8216;column&#8217;,  \/\/\u6295\u7a3f\u30bf\u30a4\u30d7<br \/>\n    &#8216;numberposts&#8217;   =&gt; 4,       \/\/\u8868\u793a\u6570<br \/>\n    &#8216;meta_key&#8217;      =&gt; &#8216;post_views_count&#8217;,<br \/>\n    &#8216;orderby&#8217;       =&gt; &#8216;meta_value_num&#8217;,<br \/>\n    &#8216;order&#8217;         =&gt; &#8216;DESC&#8217;,<br \/>\n);<br \/>\n$posts = get_posts( $args );<br \/>\nif($posts) : ?&gt;<br \/>\n&lt;?php foreach( $posts as $post ) : setup_postdata( $post ); ?&gt;<br \/>\n        \t\t&lt;div class=&#8221;sub&#8221;&gt;<\/p>\n<p>        \t\t\t<a>&#8221; class=&#8221;fix&#8221;&gt;<br \/>\n        \t\t\t\t&lt;div class=&#8221;thumb&#8221;&gt;&lt;img src=&#8221;&lt;?php echo catch_that_image(); ?&gt;&#8221; alt=&#8221;&lt;?php the_title(); ?&gt;&#8221; \/&gt;&lt;\/div&gt;<br \/>\n            \t\t\t&lt;dl&gt;<br \/>\n                \t\t\t&lt;dt&gt;&lt;?php echo get_the_title(); ?&gt;&lt;\/dt&gt;<br \/>\n                    \t\t&lt;dd&gt;&lt;?php echo get_the_date(&#8220;Y\/m\/d&#8221;); ?&gt; writer &lt;?php the_field(&#8216;writer&#8217;); ?&gt;&lt;\/dd&gt;<br \/>\n                \t\t&lt;\/dl&gt;<br \/>\n          \t\t\t<\/a><\/p>\n<p>        \t\t&lt;\/div&gt;<br \/>\n                &lt;?php endforeach; ?&gt;<br \/>\n    &lt;?php wp_reset_postdata(); ?&gt;<\/p>\n<p>               &lt;?php else : ?&gt;<br \/>\n&lt;?php endif; ?&gt;<\/p>\n<\/blockquote>\n<p>\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3057\u305f\u3002<br \/>\n\u8a18\u4e8b\u3092\u6700\u521d\u306b\u6295\u7a3f\u3057\u305f\u969b\u306f\u3001\u8a18\u4e8b\u306e\u95b2\u89a7\u6570\u304c0\u306e\u305f\u3081\u3001\u4e0a\u8a18\u306e\u90e8\u5206\u304c\u7a7a\u6b04\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<br \/>\n\u95b2\u89a7\u6570\u304c0\u306e\u5834\u5408\u3067\u3082\u3001\u6295\u7a3f\u3055\u308c\u305f\u8a18\u4e8b\u3092\u8868\u793a\u3057\u305f\u3044\u306e\u3067\u3059\u304c\u3001\u3069\u3046\u3057\u305f\u3089\u3088\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n","protected":false},"template":"","class_list":["post-196210","topic","type-topic","status-closed","hentry","topic-tag-14060","topic-tag-14354","topic-tag-17109"],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/196210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/196210\/revisions"}],"wp:attachment":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=196210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}