Apologies if the title isn't clear, can't quite think how to word this.
I'm getting a pretty standard list of posts like this:
$pageposts=$wpdb->get_results("
SELECT * FROM $wpdb->posts
WHERE post_type='post' AND post_status='publish'
ORDER BY post_date DESC LIMIT 6
", OBJECT);
$firstpost = array_shift($pageposts);
But this isn't returning what I expect. Instead of $firstpost conatining the first post in the array $pageposts (like the docs say it should), it contains the oldest - and $pageposts still also contains that post (which it shouldn't according to the docs), however the latest post is missing. I don't know what the Gordon Bennet is going on with this, I've also tried array_pop() which should do the opposite of array_shift(), but with similarly strange results (latest post shown but $firstpost still contains the wrong value).
OK I've waffled on a bit, so to conclude, here's what I'm trying to do: I want to make a single query, get the result, and print out the latest post in one area of the page and then the rest of the posts in another area. Trouble is, in the HTML, the older posts come before the one new post, so I need to split it into a separate variable and make sure the older posts don't show this new one with the others.
Does this make sense?
Any help appreciated :)
get_postspleaseget_postsis more readable and easier to use. If you're not working with a 10000000000 page requests without caching you'll barely notice any difference between raw SQL. Building on the efficiency logic, why don't youmysql_queryinstead? That's even more efficient, no?