{"id":1825,"date":"2019-01-05T16:46:39","date_gmt":"2019-01-05T07:46:39","guid":{"rendered":"http:\/\/blue-bear.jp\/kb\/?p=1825"},"modified":"2019-01-05T16:46:39","modified_gmt":"2019-01-05T07:46:39","slug":"wordpress-simple-ga-ranking%e3%81%ab%e3%82%b5%e3%83%a0%e3%83%8d%e3%82%a4%e3%83%ab%e3%81%a8%e6%8a%9c%e7%b2%8b%e3%82%92%e8%bf%bd%e5%8a%a0%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/wordpress-simple-ga-ranking%e3%81%ab%e3%82%b5%e3%83%a0%e3%83%8d%e3%82%a4%e3%83%ab%e3%81%a8%e6%8a%9c%e7%b2%8b%e3%82%92%e8%bf%bd%e5%8a%a0%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/","title":{"rendered":"[wordpress] Simple GA Ranking\u306b\u30b5\u30e0\u30cd\u30a4\u30eb\u3068\u629c\u7c8b\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u8efd\u91cf\u306a\u8a18\u4e8b\u30e9\u30f3\u30ad\u30f3\u30b0\u6a5f\u80fd\u3092\u8ffd\u52a0\u3067\u304d\u308bSimple GA Ranking\u3060\u304c\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u30b5\u30e0\u30cd\u30a4\u30eb\u3084\u629c\u7c8b\u304c\u8ffd\u52a0\u3055\u308c\u306a\u3044\u305f\u3081\u3001\u72ec\u81ea\u306b\u30b5\u30e0\u30cd\u30a4\u30eb\u3068\u629c\u7c8b(excerpt)\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5\u306f\u4ee5\u4e0b\u306e\u901a\u308a<\/p>\n<p>&nbsp;<\/p>\n<p>functions.php\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u3001\u65b0\u3057\u3044\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3092\u8ffd\u52a0<\/p>\n<pre class=\"lang:default decode:true\">\/**\r\n * \u4eba\u6c17\u8a18\u4e8b\u8868\u793a\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8-\u30da\u30fc\u30b8\u30e9\u30f3\u30ad\u30f3\u30b0\u30b5\u30e0\u30cd\u30a4\u30eb\u8868\u793a\r\n **\/\r\nclass Post_Rank_Disp_Widget extends WP_Widget {\r\n function __construct() {\r\n parent::__construct(\r\n false,\r\n $name = '\u4eba\u6c17\u8a18\u4e8b\u8868\u793a\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8', array( 'description' =&gt; 'googol GA Ranking \u4eba\u6c17\u8a18\u4e8b\u8868\u793a', )\r\n );\r\n }\r\n \r\n \/* \u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u304c\u547c\u3070\u308c\u305f\u969b\u306e\u8868\u793a\u51e6\u7406\u3092\u66f8\u304f *\/\r\n function widget($args, $instance) {\r\n extract( $args );\r\n \/\/ \u30bf\u30a4\u30c8\u30eb\u540d\u3092\u53d6\u5f97\r\n $title = apply_filters( 'widget_title_new', empty( $instance['title_new'] ) ? '\u4eba\u6c17\u8a18\u4e8b' : $instance['title_new'], $instance, $this-&gt;id_base );\r\n \r\n echo $before_widget;\r\n if ( $title )\r\n echo $before_title . $title . $after_title;\r\n \r\n \/\/ \u8868\u793a\u6570\u3092\u53d6\u5f97\r\n $entry_count = apply_filters( 'widget_entry_count', $instance['entry_count'] );\r\n if ( !$entry_count ) $entry_count = 5; \/\/\u8868\u793a\u6570\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u6642\u306f5\u306b\u3059\u308b\r\n ?&gt;\r\n &lt;div id=\"n-p-r\"&gt;\r\n &lt;?php\r\n if (function_exists('sga_ranking_get_date'))\r\n $ranking = sga_ranking_get_date();\r\n $args = array(\r\n 'post__in' =&gt; $ranking,\r\n 'posts_per_page' =&gt; $entry_count,\r\n 'orderby' =&gt; 'post__in',\r\n 'ignore_sticky_posts' =&gt; true,\r\n 'post_type' =&gt; 'any',\r\n\/\/ 'cat' =&gt; array( \u9664\u5916\u3057\u305f\u3044\u30ab\u30c6\u30b4\u30eaID\u306b\u30de\u30a4\u30ca\u30b9\u8a18\u53f7\u3092\u3064\u3051\u3066),\r\n );\r\n $my_query = new WP_Query($args);\r\n \r\n if($my_query-&gt;have_posts()):\r\n while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post();\r\n ?&gt;\r\n \r\n &lt;div class=\"n-p-r-card toc clearfix\"&gt;\r\n &lt;div class=\"term n-p-r-img\"&gt;&lt;a href=\"&lt;?php the_permalink() ?&gt;\"&gt;\r\n &lt;?php if ( has_post_thumbnail() ): \/\/ \u30b5\u30e0\u30cd\u30a4\u30eb\u3092\u6301\u3063\u3066\u3044\u308b\u3068\u304d\u306e\u51e6\u7406 ?&gt;\r\n &lt;?php the_post_thumbnail( 'thumb100' ,array( 'alt' =&gt;get_the_title())); ?&gt;\r\n &lt;?php else: \/\/ \u30b5\u30e0\u30cd\u30a4\u30eb\u3092\u6301\u3063\u3066\u3044\u306a\u3044\u3068\u304d\u306e\u51e6\u7406 ?&gt;\r\n &lt;img src=\"&lt;?php echo get_template_directory_uri(); ?&gt;\/images\/no-img.png\" alt=\"&lt;?php the_title(); ?&gt;\" width=\"100\" height=\"100\" \/&gt;\r\n &lt;?php endif; ?&gt;&lt;\/div&gt;\r\n &lt;div class=\"n-p-r-titlea excerpt\"&gt;\r\n &lt;p class=\"n-p-r-title\"&gt;&lt;a href=\"&lt;?php the_permalink(); ?&gt;\"&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n &lt;p class=\"n-p-r-excerpt\"&gt;&lt;?php echo apply_filters( 'thk_excerpt_no_break', 40 ); ?&gt;&lt;\/p&gt;\r\n &lt;\/div&gt;\r\n &lt;\/div&gt;\r\n &lt;?php endwhile; endif; ?&gt;\r\n &lt;?php wp_reset_postdata(); ?&gt;\r\n &lt;\/div&gt;\r\n &lt;?php\r\n echo $after_widget;\r\n }\r\n \r\n \/*\u3000\u7ba1\u7406\u753b\u9762\u306e\u8a2d\u5b9a\u3068\u304b\u8868\u793a\u7528\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3000*\/\r\n function form($instance) {\r\n if(empty($instance)) {\r\n $instance = array('title_new' =&gt; null, 'entry_count' =&gt; null);\r\n }\r\n $title_new = esc_attr($instance['title_new']);\r\n $entry_count = esc_attr($instance['entry_count']);\r\n ?&gt;\r\n &lt;?php \/\/\u30bf\u30a4\u30c8\u30eb\u5165\u529b\u30d5\u30a9\u30fc\u30e0 ?&gt;\r\n &lt;p&gt;\r\n &lt;label for=\"&lt;?php echo $this-&gt;get_field_id('title_new'); ?&gt;\"&gt;\r\n &lt;?php echo('\u4eba\u6c17\u8a18\u4e8b\u30e9\u30f3\u30ad\u30f3\u30b0\u306e\u30bf\u30a4\u30c8\u30eb'); ?&gt;\r\n &lt;\/label&gt;\r\n &lt;input class=\"widefat\" id=\"&lt;?php echo $this-&gt;get_field_id('title_new'); ?&gt;\" name=\"&lt;?php echo $this-&gt;get_field_name('title_new'); ?&gt;\" type=\"text\" value=\"&lt;?php echo $title_new; ?&gt;\" \/&gt;\r\n &lt;\/p&gt;\r\n &lt;?php \/\/\u8868\u793a\u6570\u5165\u529b\u30d5\u30a9\u30fc\u30e0 ?&gt;\r\n &lt;p&gt;\r\n &lt;label for=\"&lt;?php echo $this-&gt;get_field_id('entry_count'); ?&gt;\"&gt;\r\n &lt;?php echo('\u8868\u793a\u6570\uff08\u534a\u89d2\u6570\u5b57\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\uff1a5\uff09'); ?&gt;\r\n &lt;\/label&gt;\r\n &lt;input class=\"widefat\" id=\"&lt;?php echo $this-&gt;get_field_id('entry_count'); ?&gt;\" name=\"&lt;?php echo $this-&gt;get_field_name('entry_count'); ?&gt;\" type=\"text\" value=\"&lt;?php echo $entry_count; ?&gt;\" \/&gt;\r\n &lt;\/p&gt;\r\n &lt;?php\r\n }\r\n \r\n \/*\u3000\u7ba1\u7406\u753b\u9762\u3067\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u305f\u6642\u306e\u51e6\u7406\u3092\u66f8\u304f\u3000*\/\r\n function update($new_instance, $old_instance) {\r\n $instance = $old_instance;\r\n $instance['title_new'] = strip_tags($new_instance['title_new']);\r\n $instance['entry_count'] = strip_tags($new_instance['entry_count']);\r\n return $instance;\r\n }\r\n}\r\nadd_action('widgets_init', function(){register_widget(\"Post_Rank_Disp_Widget\");});\r\n?&gt;<\/pre>\n<p>CSS\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0<\/p>\n<pre class=\"lang:default decode:true\">\/************************************\r\n**\u3000GA\r\n************************************\/\r\n.n-p-r-img img{\r\n margin: 0 10px 0 0;\r\n padding: 1px;\r\n}\r\n.n-p-r-titlea {\r\n}\r\n.n-p-r-title {\r\nfont-weight: bold;\r\nfont-size: 1.35rem;\r\n}\r\n.n-p-r-excerpt {\r\nfont-size: 1.25rem;\r\n}\r\n.n-p-r-card {\r\n padding: 15px 0;\r\n border-bottom: 1px dotted #ccc;\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8efd\u91cf\u306a\u8a18\u4e8b\u30e9\u30f3\u30ad\u30f3\u30b0\u6a5f\u80fd\u3092\u8ffd\u52a0\u3067\u304d\u308bSi<\/p>\n","protected":false},"author":1,"featured_media":54,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1825"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=1825"}],"version-history":[{"count":1,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1825\/revisions"}],"predecessor-version":[{"id":1826,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1825\/revisions\/1826"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media\/54"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=1825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=1825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=1825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}