Hi,
I need to show only the posts that have the latest date of the custom date field. (This is not the publish date of the post.)
In the old site this was queried with SELECT MAX(thedatefield). In Toolset there are many date parameters, but it seems there is no such as "select the biggest date" - and since I don't know PHP I don't quite know how to achieve this.
Perhaps I should
A. create a shortcode, say [LATESTDATE], which returns the latest date of the posts
B. filter posts where date = [LATESTDATE]
Hi Nigel, thank you. Sorry for being unclear. I don't need to show the latest posts. I need to
1. first know what is the latest date of this certain custom date field of all the custom posts
2. then show all the posts that have this same date.
The custom date field is not the post creation or last update field. It's kind of a "decision date". So there have been made some important decisions on certain date and I want to show all the decisions that were made last time.
But it is still the last of these dates that you want to display posts for, right?
So the solution I described above would work (ordering the posts by this custom date field rather than the post_date or post_modified_date fields), except the problem is you don't know how many posts to display, there could be 1 or there could be six.
You can still do this without coding.
You create a View as described, and in the output section use the Loop Wizard and choose the List with separators format, and only output the raw date field value (e.g. use wpv-post-field shortcode to output it, or add the output='raw' attribute to a types shortcode).
So, this View will simply output the date (in timestamp format) of the custom date field that represents the latest of such dates.
Now you need a second View, similar to the first but without the limit or order options, which includes a Query Filter for the date field where the value comes from a shortcode attribute. When you insert the View you then add such a shortcode attribute, where its value comes from your first View.
Then the second View will output all of the posts which have the same custom date field value as the first View (which shows the last of such dates).
Hi Nigel, sounds like a very clever approach, but I can't make it work.
I have the first view ready. In the second view I have this query:
Select items with field:
Päätöspäivämäärä is a NUMBER equal to VIEW_PARAM(uusintp)
The "päätöspäivämäärä" is the date field. So what should the VIEW_PARAM be? This "uusintp" is the first view's name, but it doesn't work. And instead of NUMBER I've tried the other options too.