サポート » テーマ » テーマ「DW FOCUS」で人気記事が更新されない

  • DW FOCUSというテーマを使用しています。
    このテーマには「POPULAR NEWS」というウィジェットがあり、いわゆる人気の記事を表示することができます。
    しかし、これが表示はされるものの、いつまでたっても更新されません。
    もっとアクセスされている記事は他にたくさんあるのですが、いつも同じ記事が表示されています。
    テーマの提供元のフォーラムでも質問し、メールも送っているのですが、音沙汰がなく途方に暮れています。

    widgetのphpファイルで関係ありそうな部分は以下のとおりです。

    class dw_focus_popular_news_Widget extends dw_focus_recents_posts_Widget {
        function __construct() {
            $widget_ops = array('classname' => 'dw_focus_popular_posts latest-news', 'description' => __( 'Display most viewed news with many settings', 'dw_focus' ) );
            parent::__construct('dw_focus_popular_news', __( 'DW Focus: Popular News', 'dw_focus' ), $widget_ops);
            $this->alt_option_name = 'widget_popular_entries';
    
            add_action( 'save_post', array(&$this, 'flush_widget_cache') );
            add_action( 'deleted_post', array(&$this, 'flush_widget_cache') );
            add_action( 'switch_theme', array(&$this, 'flush_widget_cache') );
        }
    
        function query($instance){
    
            if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
                $number = 10;
    
            $category = $instance['category'];
            if( is_category() && dw_focus_sidebar_has_widget( 'dw_focus_category_sidebar', $this->id ) ){
    
                $category = get_query_var( 'cat' );
            }
            $post_with_views = new WP_Query(
                array(
                    'posts_per_page'    => $number,
                    'no_found_rows'         => true,
                    'post_status'           => 'publish',
                    'ignore_sticky_posts'   => true,
                    'cat'              => $category,
                    'orderby'   =>  "meta_value_num",
                    'meta_key'  =>  '_views',
                    'order' =>  'DESC',
                )
            );
            if( $post_with_views->post_count < $number ) {
                $post_dont_with_views = new WP_Query( array(
                        'posts_per_page'    => $number - $post_with_views->post_count ,
                        'no_found_rows'         => true,
                        'post_status'           => 'publish',
                        'ignore_sticky_posts'   => true,
                        'cat'              => $category,
                        'meta_query'    =>  array(
                                array(
                                    'key'  =>  '_views',
                                    'compare'  =>  'NOT EXISTS',
                                )
                            )
    
                ) );
                $post_with_views->posts = array_merge($post_with_views->posts,$post_dont_with_views->posts);
                $post_with_views->post_count += $post_dont_with_views->post_count;
            }
    
            return $post_with_views;
        }
    
    }

    しかし、素人なものでなにが原因で更新されないのか、まったくわからずお手上げ状態です。
    なにか原因と思われる点はありますでしょうか?

1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック投稿者 Teppei222

    (@teppei222)

    すみません、一応自己解決できたようです。
    WP-PotView というプラグインを使用し、上記widgetのphpの
    ‘_views’,
    の部分を
    ‘views’,
    に変更したところ更新されました。

1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック「テーマ「DW FOCUS」で人気記事が更新されない」には新たに返信することはできません。