[Code Snippet] WordPress : Current Week Post
Posted on February 15, 2010 and got 3 shouts so farSometimes we want to show current week posts in our blog, it can easily do with basic WordPress’s query_posts function. Firstly we grab current week number of a year with php function date(‘W’) (ISO-8601) then add its value to the query, and voila we’ve just created current week posts from our blog. Let’s see the code :
/* Help the query to create pagination */
$limit = get_option('posts_per_page');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
/* Grab this week number of a year (ISO-8601) */
$thisWeek = date('W');
/* Start to query! */
$currentPosts = query_posts('showposts=' . $limit .
'&paged=' . $paged .
'&w='.$thisWeek);

What They Shouts
Shout Something
The Artist
Popular Post
Stuff & Community News
Tags Collection
maknyoss lah, biarpun gue gak ngerti,,
saia juga kurang begitu yakin klo yg nulis ini mengerti, wkwkwkwk..
This is awesome – Just what I needed! Thx!