anyone have thoughts on how I would go about making this work. The problem is there are 2 date fields that could be in use. So I want to see if one is in the range and use that if not use the other. Can’t seem to find any documentation that has any help.
I looked at this when you first posted, but I don’t really have an answer. It looks like you are trying to order the posts by two different fields as if they are one field. You can do a query to make sure that one of the fields is in the correct range, but you can’t order them by the values in these field….. well, you can, but not at the same time. For example, you could order them by the “end date” and then order them by the “start date”, or you can order them by “end date 1” and then by “end date 2”. Hopefully I’ve explained this well enough that you see the problem.
If you need to order by both of these fields then your best bet is to do what you suggest. Create an acf/save_post filter that looks at the date fields and takes the one you want to sort by and puts them into another custom meta field using update_post_meta() and then order the posts by this single field.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users