Trying to pull last 30 day posts
-
Greetings! So I’m trying to pull all posts for this month by using a date I enter into the Custom Fields. I think I’m very close, but I just need a tiny bit of help. Here’s my code that I use in my sidebar:
<?php mysql_connect(localhost, root, noxalaction); mysql_select_db(wpmu); $query = mysql_query("SELECT * FROM wp_posts,wp_postmeta WHERE wp_posts.id = wp_postmeta.post_id AND meta_key = 'Case Law Date' AND post_status = 'publish' AND post_type = 'post' ORDER BY meta_key LIMIT 0,5"); while($r = mysql_fetch_array($query)) { $postdate = $r["meta_key"]; $unixPostdate = strtotime($postdate); $mondaydate = strtotime('Last Monday'); if(date('M')=="") $mondaydate = strtotime('Today'); if($unixPostdate>$mondaydate) { echo "<a href=\"".$r["guid"]."\">".$r["post_title"]."</a>"; }; }; ?>
I found this code from this post and can’t figure out how to adapt it for month. Any help is great appreciated!
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘Trying to pull last 30 day posts’ is closed to new replies.