I want to add a filter which will allow users to filter query results by a custom field called 'publication date' in the search view and in archives. The custom field is a number field. I want the filter to allow the user to enter a date range - ideally in two fields, 'from' and 'to' - and if an article has a publication date within that range, it will come up in the query. For example, an article written in 2013 should come up when the user enters 2000 in the 'from' field and 2020 in the 'to' field. How do I do that?
There is a twist!
Some articles have more than one date. It's because they have different editions or have been republished. On the back end, I simply 'Allow multiple instances of this field'. I would like the filter to find the entry on any of the publication dates. For example, an article written in 1987 that was reprinted in 2013 should come up when the user enters 2000 - 2020, but also when they enter 1950 - 2000. Is this possible?
There is an even worse twist!
Some texts are collections that have been written over a longer period of time. For those, I enter date ranges in the 'publication year' field, for example: 2005-2015. It would be amazing if the filter could find such a text if the search query hits any of the years in the range, e.g. if the user searches for 2000 - 2010, or 2010 - 2020, or even 2007 - 2008. Is this possible?
I am using the original text editor, not the blocks one.
Hello. Thank you for contacting the Toolset support.
First of all, I would like to know what plugins you are using and I need to review the content structure you have currently.
Can you please send me details about with what post type you added the date custom field and send me admin access details and let me review your current structure and once I review it, I will be able to guide you in the right direction.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
When I try to login using the admin access details you shared I got the following error:
Error: The password you entered for the username testadmin is incorrect.
Can you please send me working admin access details.
As well as tell me where you created the repeated number field with what post type.
I have set the next reply to private which means only you and I have access to it.
It offers "Publication year From" and "Publication year To" textbox where you can add the year range and perform the search. I hope the above solution will help you to resolve the issue.
Hi Minesh,
Thank you for your help, this seems to work well with both single dates and repeat field. Is there a chance this could still work with the date ranges? As in, the 'even worse twist' from my first post? At the moment, I can't even enter a range in the date field because it only allows numbers...
Thanks for clarifying. Would it be possible in some other way, e.g. if I set this up not as a number field but a text field? Or perhaps a taxonomy? Any ideas and suggestions welcome.
Also, is there some way to only display the first of the values from the multiple-instance field? That is, I want it to be found when people look for any of the publication dates, but I only want to display one of them on the front end.
New threads created by Minesh and linked to this one are listed below:
Thanks for clarifying. Would it be possible in some other way, e.g. if I set this up not as a number field but a text field? Or perhaps a taxonomy? Any ideas and suggestions welcome.
====>
I already seen that you added textfield as from and to to find year range.
As per our support policy, we entertain only one question per ticket. This will help other users searching on the forum as well as help us to write correct problem resolution summery for the original issue reported.