开发者

How can i display the posts per week in a particular month?

开发者 https://www.devze.com 2023-01-18 12:24 出处:网络
I have to display the posts as the following September 2010 Friday September 24, 2010 post1 post2 . . . Friday September 17, 2010

I have to display the posts as the following

September 2010

Friday September 24, 2010

post1
post2
.
.
.

Friday September 17, 2010

post1
post2
.
.
.

Friday September 10, 2010

post1
post2
.
.
.

Friday September 03, 2010

post1
post2
.
.
.

can any one tell, how can do this?, or which function should i use?

I have used the following function and i got all the post in current month

query_posts("year=$current_year&monthnum=$current_mon开发者_开发知识库th")

How can i show the posts per week of this month?

is it work query_posts(""year=$current_year&monthnum=$current_month&post_date >$startDate&post_date <=$endDate")

Or what is another good way?


So this is actually very simple, all you need to do is print the week heading every time the week changes. If you want this to happen every Friday, just have something like this in the loop inside the while statement:

<?php
if(get_the_time("N")==5):
?>
<h1><?php the_time(); ?></h1>
<?php endif; ?>

You'll need some logic to determine if the first post is not a Friday, and compensate for the difference. But this is pretty close I think.

0

精彩评论

暂无评论...
验证码 换一张
取 消