I wish to show in my front page a number of posts determined by the following criteria: show all posts from current month (actually from the month corresponding to the most recent post) ; but if that number is less that (say) 8, then show the 8 most recent posts.
Assuming that I know that no month will have more than (say) 20 posts, I'd tought of setting posts_per_page = 20, grab normally the most recent 20 posts, and afterwards do the appropiate trimming (slice) in php. (To do it in SQL seems too convoluted)
BTW: at first I thought that
add_filter( 'posts_results', ... ) would be appropiate, but it's difficult to discriminate there whether the query corresponds to the main loop, or to some other query (eg., the Most-recent-posts widget...). I then coded the logic in the theme, in the
The problem is that WP-query does not seem to support -cleanly- a trim of the posts... I must manually reassign the
count attribute (I think that the
rewind() method should recompute the
Do you feel this is too dirty? Any other ideas?