Hi,
I've read some other posts about adding a date range selection to a view's filter. I've tried it and it just says:
'Empty field values or incorrect field defined. | Empty field values or incorrect field defined.'
Here is the code I've added to the filter.
[wpml-string context="wpv-views"][wpv-control field="wpv-post-date" url_param="wpv-post-date_min" type="datepicker" ][/wpml-string] | [wpml-string context="wpv-views"][wpv-control field="wpv-post-date" url_param="wpv-post-date_max" type="datepicker"][/wpml-string]
In case it's easier to see the while filter code this is what I've got:
[wpv-filter-start hide="false"]
[wpv-pagination]Showing page: [wpv-pager-current-page style="drop_down"] of [wpv-pager-num-page] | [wpv-pager-prev-page][wpml-string context="wpv-views"]Previous[/wpml-string][/wpv-pager-prev-page] [wpv-pager-next-page][wpml-string context="wpv-views"]Next[/wpml-string][/wpv-pager-next-page][/wpv-pagination]
<br><br>
<strong>Change Filter Settings:</strong>
<br>
[wpv-filter-controls]
[wpml-string context="wpv-views"]Department: [/wpml-string] [wpv-control field="department" url_param="department" type="select" auto_fill_default="All" auto_fill="wpcf-department" auto_fill_sort="asc"] <span style="padding-left:20px;padding-right:20px;"> </span> [wpml-string context="wpv-views"]Issue Priority: [/wpml-string] [wpv-control field="issue-priority" url_param="issue-priority" type="select" auto_fill_default="All" auto_fill="wpcf-issue-priority" auto_fill_sort="asc"] <span style="padding-left:20px;padding-right:20px;"> </span>
<br><br>
Sort order date: [wpv-sort-orderby type="select" options="post_date" label_for_post_date="Sort by" orderby_descending_for="post_date"][wpv-sort-order type="radio" options="desc,asc" label_for_asc="Ascending" label_for_desc="Descending" label_asc_for_post_date="Older first" label_desc_for_post_date="Newer first"]
<br>
Select Dates: [wpml-string context="wpv-views"][wpv-control field="wpv-post-date" url_param="wpv-post-date_min" type="datepicker" ][/wpml-string] | [wpml-string context="wpv-views"][wpv-control field="wpv-post-date" url_param="wpv-post-date_max" type="datepicker"][/wpml-string]
[/wpv-filter-controls]
[wpv-filter-end]
<br>
<div style="clear: both;"></div>
<hr>
Any ideas what I'm doing wrong. Any help is muchly appreciated. Thanks
I think the main problem here is that you're trying to filter on post date using the syntax for a custom field. Here's the syntax you're using:
[wpv-control field="wpv-post-date" url_param="wpv-post-date_min" type="datepicker" ]
The field slug wpv-post-date won't work this way. It's not a custom field, it's a native WordPress field, so custom controls don't apply.
Please review the date filtering documentation here:
https://toolset.com/documentation/user-guides/filtering-views-query-by-date/
Use multiple inputs (Year, Month, Day, Hour, etc) to define minimum and maximum dates. This is the preferred method of filtering by date, but it does not allow datepickers.
An alternate method will allow you to use datepickers. Create a new custom field on your posts called "date-range". Set that value automatically whenever the post is published to include today's date. You can use the WordPress save_data hook to handle this. Then you can use datepicker style filters to filter based on this custom field instead of the actual post date. It's a bit convoluted but I can help you set it up if you really would prefer to use datepickers here.
Please let me know if you need additional assistance here.
Hi Christian,
Looking at the options I think the custom date field and the date picker looks like the best options in terms of it looking the best and probably setting up.
The only challenge is how to quickly copy across the existing wordpress published date to the custom field? Is there a quick way of doing this to avoid manually entering them all?
Hi Again,
I've set up the custom date field but can't see where I would enter some sort of command like copy data from wordpress date field. You mentioned needing a 'WordPress save_data hook' .. please can I ask how this is done?
Yes, you'll need to add some custom PHP code to your functions.php file. If you are using a child theme, you can make the modifications in wp-content/themes/your-child-theme-folder/functions.php.
If you're not comfortable editing files, I can help if you give me FTP access. I will enable private reply fields here so you can share in confidence.
I'll also need to know the post type(s) that will include this date range field. If it's a custom post type, I need to know the slug.
Okay I'm making a clone of your site now so I can perform the necessary changes locally without affecting your live site. Here's what I will do:
- Set up a child theme of your Twenty Fourteen theme so I am not changing the files directly in TwentyFourteen.
- Add the changes to functions.php in the new child theme
- Activate the child theme and verify everything works locally
- Then I will upload the child theme to your live site and activate it with those changes
- Then I will update you that the changes are ready to review
Please standby and I will update you shortly
That's great support! Thank you
Standing by ;o)
Hmmm, the tools I have access to aren't working to create a clone. I've seen problems on this hosting platform before, so I suspect they don't allow certain cloning tools. I found this article on wpengine's support site:
hidden link
Could you follow these steps to create a clone, or grant me access so I can do it myself?
Hi,
Just a thought. I've given you access details to the staging site, which I created for you to test in.
So you should be fine to change anything in the staging site and it not impact the live site.
Is that ok?
Yes I considered this as well but the FTP credentials you sent don't seem to work for me. Can you double check those? I will enable the private reply fields again.
Unfortunately I still can't access it, and I'm using port 2222. I asked another supporter here to try the credentials as well and they are unable to access the server. Is it possible there is an IP restriction in place?
Hi,
Sorry .. for some reasons WPEngine have put the wrong url on the sftp settings.
On the sftp host url can you replace '.....sftp.wpengine.com' with '.....staging.wpengine.com'
And that seems to work for me.
I'm really sorry this is taking a long time to sort
No, sorry but I still get "Authentication Failed" error. I've tried both active and passive modes, sftp, port 222...any ideas?
Hi
Here is a screenshot of the settings i'm using and managing to connect. I'm using FileZilla
The password is the one beginning with eGa...........
Are your settings the same?
Hi,
Here is a screenshot of the settings I've used and managed to connect ok. I'm using FileZilla.
The password is the one beginning with 'eGa...........'
Just in case - you mentioned port 222 ... in that correct or did you mean 2222 .... it only works with 2222.
Are your settings the same as the screenshot?