Thread Starter
TOMTH
(@tomth)
Bump, anyone familiar with sorting algorhytms in WordPress?
Use the Order Parameters of the WP_Query class. Should help you out there.
Thread Starter
TOMTH
(@tomth)
Wow Jerry, jack of all trades? π
Thread Starter
TOMTH
(@tomth)
The trouble is I think I have 3 queries. And arrays aren’t my forte.
Thread Starter
TOMTH
(@tomth)
So this is what it does now.
Loop through cat 6, get newest post and post it.
Loop through cat 4, get newest post and post it.
Post all other posts (newest first).
First post is always category 6 and second post always category 4, even though a post in category 1 is newer than one in cat 4 or 6.
Okay so query one and two (cat 6 & 4 respectively) are fine, but query 3, should just exclude cats 6 & 4.
Your third query instead of reading ‘cat=1’ can read ‘cat=-6,-4’ therefore excluding said category ids.
Thread Starter
TOMTH
(@tomth)
That doesn’t change anything. Instead of sorting ALL the posts by date, it will first show result from query 1, result from query 2, result from query 3. Being 1 post from cat 6, 1 post from cat 4, and the rest. This is fine, except I can’t get it all to be sorted by date.
I’m not sure if this is clearer?
Okay, so you want to query all categories, (1, 4, & 6) but you want only one post from cats 4 & 6, and you still want them to be in chronological order.
EDIT: I don’t know if that’s possible haha
Thread Starter
TOMTH
(@tomth)
Solved it with a workaround, but would be better if I could get it automated. Created an extra two categories, which will be manually controlled to only have 1 post in it. Each time a new post is created, the category needs to be edited.