On my website I have a "Breaking News" section which shows the most recent 4 stories in the "Breaking News" Category.
Under this I have a featured news section which displays 5 more stories from the "Breaking News" Category. I get these posts by simply setting the offset to 4 in a WP_Query
What I want to do is make an adjustment to the featured news section. So that it still pulls in 5 of the latest stories from Breaking News, but if a story is added to a "Featured News" category, that it pulls that in.
Some pseduo code would be something like
Get the 5 latest posts from Breaking News with Offset of 4 and from Featured News with Offset 0
Seems pretty simple when it's written like that, but I can't seem to actually get it to work. I can't get WP_Query to accept an offset from one category and not the other.
I've tried this
$featuredPosts = new WP_Query( array(
'posts_per_page' => 5,
'cat' => 169,
'offset' => 4
),
array(
'posts_per_page' => 5,
'cat' => 172,
'offset' => 0) );
But this only gives me the first 5 posts from cat 169 and ignores the second query array from 172.
I have also tried storing all the id's of posts already outputted in "Breaking News" and then not outputting them again so I can do an easier query (Get last 5 from breaking&featured) but the problem there is it won't always output 5 posts since it will be excluding some of the breaking news ones.
Maybe I'm completely over thinking this and there's an easier way, has anyone any ideas?
UNION
, for example.