A client wanted their blog post page to show entries only from the current calendar week starting on Monday. So if it was Thursday, the index page would show posts from the last four days, Monday-Thursday. If there ever was a mission for query_posts(), this was it.

$weekstart = date("W");
query_posts('w='.$weekstart);

(Put that above The Loop. It uses PHP’s date() function to get the current calendar week’s first day, which by definition and luck happens to be Monday.)

Fine, but hold on: search broke. A search would return nothing. Who was the culprit? Why it’s query_posts(). I was shocked, shocked (sarcasm).

Here’s how I got around it: I figured if I could make search use another template, one without the offending function, I’d be fine. I looked into that but didn’t find much (didn’t spend too much time looking though). Then I had a better idea: don’t move search, move the index page.

create a new template with your troublemaking query_posts() on it, name it Home