4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Wordpressでよくみるパーツの実装

Last updated at Posted at 2016-05-15

WordPress投稿一覧にページビュー数を表示

  1. Wordpress Popular Postsのプラグインをインストール
  2. function.phpに下記ソースコード追加
function.php
//管理画面での記事一覧カラムカスタマイズ
//WordpressPoplarPostのビューカウントを表示する
function admin_posts_columns($columns) {
    $columns['subtitle'] = "ビュー";
    return $columns;
}
function add_admincolumn($column_name, $post_id) {
    if( $column_name == 'subtitle' ) {
        echo wpp_get_views($post_id, 'monthly', true);//←ここの値で集計期間変更dailyとかweekly全部の場合はall
    }
}
if ( function_exists('wpp_get_views') ) {
    add_filter( 'manage_posts_columns', 'admin_posts_columns' );
    add_action( 'manage_posts_custom_column', 'add_admincolumn', 10, 2 );
}

参照:WordPress投稿一覧にページビュー数を表示する方法。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?