I recently posted a similar question, but it didn't seem anyone could help - I've thought of a simpler method below if anyone can offer any advice? Been trying for 3 days on this with no luck, am sure it's something fairly simple but it's a bit beyond my skill set I'm afraid!
Essentially I'd like to add some code to functions.php so that for each category/tag/custom taxonomy archive:
From the current query, get the entire list of posts and check to see if any posts are in cat ID 283 (expired)
if not "Expired", order all posts by meta value "savings" DESC
Then list the remaining "Expired" posts beneath the above list (in any order - although if possible by post ID DESC)
- Get entire post ID list for current taxonomy.
- Get all non expired posts and order by meta value "savings" DESC
- Get all expired posts and order by post ID DESC
- Combine these into one list so they appear Not Expired then Expired
- Apply to current taxonomy so that it works with pagination.
I've tried loads of different pieces of code from here over the last few days, and I can either get it to:
Order all posts by the meta key, or
Order all posts non expired, then expired (although this has a few issues with pagination)
However I haven't managed to combine the two.
There's a couple of half solutions here: Display all posts in category, with specific tag posts at top
which I've modified so non expired posts are listed above expired ones, but I didn't manage to further combine it with ordering by meta key.
I've also tried https://github.com/birgire/wp-combine-queries without much luck.
If anyone has any pointers I'd be very grateful.
Thanks so much in advance