I run an events company whose website uses a custom post type system for posts (blog), events and tickets all stored as CPT's in the DB.
On the guestlist (which counts 'ticket' custom posts if the event [post] number == current post) I would like to implement a "New Customer" tag to prompt the host to look out for them.
There are two problems with this: you cannot search for the oldest 'ticket' post, as they may not have bought them in chronological order, and you cannot get all tickets and order by post number as they may not have been added to the site in chronological order either.
The two ways I can think of getting around this is either:
By multiple search arrays, i.e. query TICKET > to get USER > get all TICKETS for USER NUMBER > get EVENT [POST] NUMBERS from those tickets (stored as meta) > get EVENTS by post number > - SORT ARRAY BY DATE of event > IF FIRST EVENT IN THAT ARRAY == CURRENT EVENT [post] NUMBER echo NEW CUSTOMER
This seems to be an awfully long way around and I am a little reluctant to try and make all that work as a relatively novice coder.
(2) Somehow retrospectively adding a 'date of event' meta data tag to all ticket posts and then I can directly query them.... Much easier, but I am unsure how to then re-translate that 010214 so that the query recognises it as a date rather than a number...
Number (2) would be ideal but I can't find any information as to how to add all this data retrospectively, and then for future posts - all the data is there in the system but all searches for information lead me to people talking about going back and batch adding search engine meta, not WordPress post meta.
I started coding Number (1) and realised the mountain ahead of me and stopped - if anyone would like that portion of the code though, I can still post it...
Thanks in advance, sorry for the long question - trying to equip any helpers with as much information as possible.
EDIT: A way around this could be actually to use the event page itself as each
$ticketare called there.
Structure could be:
write meta to `$ticket` with meta key = 'event_date' value = $eventDay [= date( 'dmy', $event->start );]
Then a simple query to find all user tickets, and order by this new meta tag 'event_date'.
If first entry event number == current post, BINGO!