We have created a view to display the 3 most read Articles (CPT). This works perfectly in Dutch and French, but after more than a year, the list in English is still empty. However, in the DB we do see a value for the meta_key "post_views_count".
We set the number of views in the single-article.php in the loop with
<?php setPostViews(get_the_ID()); ?>
which I think we got from here hidden link
Hi, I'll be glad to take a look.
- Is post 14867 an English post?
- What is the primary language of this site?
- If you temporarily switch the Order to post date instead of post_views_count, are English posts visible?
- Is post 14867 an English post? YES
- What is the primary language of this site? DUTCH
- If you temporarily switch the Order to post date instead of post_views_count, are English posts visible? NO
Okay that's odd. May I log in and see how this is set up? Private reply fields are active here. If I need to run additional tests, I will install a plugin like Duplicator Pro to create a site clone.
In my local clone, I activated the parent Avada theme and I can now see results appear on the English homepage in View ID 930 (Homepage - Articles - Most Read). The only plugins I have active are Types, Views, Fusion Builder, Fusion Core, WPML Media, WPML CMS, WPML String Translation, and WPML Translation Management.
Can you perform the same test on your site and tell me the results?
A bit more information - the problem goes away when I comment out this filter in the child theme:
add_filter( 'wpv_filter_query', 'custom_date_filter', 101, 3);
function custom_date_filter( $view_args, $view_settings, $view_id ) {
if ( $view_id == 930 ) {
$view_args['date_query'] = array(
array(
'column' => 'post_date_gmt',
'after' => '4 months ago',
'before' => 'tomorrow'
)
);
}
return $view_args;
}
That's where I would focus troubleshooting.
But that is a custom script Nigel gave me (https://toolset.com/forums/topic/how-to-filter-posts-from-the-last-4-months/)
We need this extra filter, otherwise we would get most read articles from maybe 2002 which are no longer relevant. Toolset has a Date condition filter that works almost like this code snippet but you first have to set a year and then the last x months. But each January 1st, our list would be empty as there won't be 3 articles in 2019 yet.
Update: how incredibly stupid of me, there are no EN posts in the last 4 months. I assumed wrongly because in NL and FR, there is a post every week, sometimes every day.
Okay that makes sense. Let me know if you need any further assistance here.