Skip Navigation

[Resolved] Can't filter view by date after importing with WP All Import

This support ticket is created 5 years, 10 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Luo Yang 5 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1181059

Hi!

I'm using WP All Import in combination with a cron job to import audio files from an XML file. This also imports a date, that is stored in a Toolset custom date field. But if I want to filter these audio files by date in a view, I get a 'no items found' message.

Is it possible the date field WP All Import creates can't be read by Toolset? If I open a single page in the backend the date field shows as normal.

hidden link

Hope you can help me fix this. 🙂

#1181281

Hi,

Thanks for the details, I can login into your website and see the problem.
Here are what I found:
1) you are using filter in view
hidden link
Date uitzending is een string gelijk aan URL_PARAM(wpv-wpcf-date-uitzending)

Types custom date field stores value in timestamp format, so it should be:
Date uitzending is een nummer gelijk aan URL_PARAM(wpv-wpcf-date-uitzending)

See our document:
https://toolset.com/documentation/user-guides/date-filters/

But I have tried it, the problem still persists, so the problem is abnormal.

2) Please try these:
a) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2019, and test again
b) If the problem still persists, please provide database dump file(ZIP file) of your website, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1181316
#1181357

Thanks for the details, I am downloading the files, will update here if there is anything found

#1181362

Here are what I found,

The problem is that you are using other plugin to import the custom date field "date-uitzending" value, it should be the timestamp value of 00:00:00 of specific date, but it seems you have imported some other timestamp values.

You can try these:
1) Edit the post view "Uitzendingen", in section "Loop item in Uitzendingen", display custom date field "date-uitzending" value in timestamp format, like this:
[types field='datum-uitzending' style='text' format='U'][/types]

Test it in front-end, for example:
in post "audio/2019/01/10/5c36eea50c0ef5c36eea50c12a.mp4", it output the value: 1547103964
but the accurate value for date 2019/01/10 00:00:00 should be: 1547078400

So it conducts the problem, they are not equal to each other, and Views outputs the result:
No items found

I suggest you import the data again, setup the date field value manually, you can get the timestamp value by using view, for example:
hidden link

There is a URL parameter "wpv-wpcf-date-uitzending", value "1547078400" is the timestamp of date 2019/01/10

#1181364

Hi Luo,

Thanks for the solution.

I'm importing a XML file, with the date value {pubDate[1]}. The plugin says 'use any format supported by the php strtotime function'.

Do you have any idea how I can use this function to import it the right way?

Thanks,

Tim

#1182007

You can try the PHP function strtotime, like this:

echo strtotime('2019/01/10');

It should be able to output the timestamp value like this:
1547078400

More help:
hidden link

#1182391

Hi Luo,

Thanks, but I can't get this to work.

The date get's imported in a custom field made with Toolset, in a way that Toolset can read and show it. So I don't understand why I can't use the Toolset View filters to filter by date. Is there a fix for this?

There is a file imported every hour, so setting the date manually as you suggested isn't really an option.

Thanks,

Tim

#1183356

Dear Tim,

Please check my answer above:
https://toolset.com/forums/topic/cant-filter-view-by-date-after-importing-with-wp-all-import/#post-1181362
It is expected result, custom date field "date-uitzending" value isn't accurate value for date 2019/01/10 00:00:00, so the date filter won't work, and the problem is in your importing tools.

You can use strtotime function to get today's 00:00:00 timestamp, like this:
strtotime('today');

this is same result as:
strtotime('2019/1/14');