You will have to use a custom query to get the sql row number
as extra parameter and then just check in php if $row_num % 2
see here on how to get the row number in a mysql select statement
You can do a custom sql query in php (and bypass wordpress) or even use wordpress query to alter the default WP query to get the posts
Note that this method assumes you will select at least 2 posts and is efficient (as mysql handles the selecting) and will work regardles if post ids
are indeed chronologicaly ordered or not or in any other ordering needed. For a single post, probably two select statements (or a combined select statement) will be needed (see below for an alternative).
An alternative is to select the count
of all posts which come before the needed post (with given ordering), this would also give you the row number
(or row number +1
) and then proceed as previously. This will probably need two select statements (i.e one for the post
and one for the count
of all previous posts up to the given post acording to given ordering, e.g by date
)