Skip Navigation

[Resolved] This one particular View does not work in English

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a View filtered by post date. It does not show any results in one language, but works in other languages.

Solution: The View is working as expected, there are no matching posts in this language.

This support ticket is created 5 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 8 replies, has 2 voices.

Last updated by kristofG 5 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1082944
Screenshot_22.png
Screenshot_21.png

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

#1083209

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?

#1084434

- 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

#1084688

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.

#1084818
Screen Shot 2018-08-16 at 3.47.04 PM.png

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?

#1084825

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.

#1085511

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.

#1087072

Okay that makes sense. Let me know if you need any further assistance here.

#1087401

thank you

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.