query Posts: Last 30 days & specific category – 50% working
-
Hi,
I’m trying to add a new loop to my index.php page, but can’t figure out how to add only specific categories to the query.
I’m using the following code to output the last 30 days of posts:
<?php function filter_where($where = '') { //posts in the last 30 days $where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'"; return $where; } add_filter('posts_where', 'filter_where'); query_posts($query_string); ?>
That works fine. But what I’d like to add to that query is the ability to only return posts from a specific category – cat=17.
I’ve spent the last few hours trying to add an array using ($args) to the query but I don’t really know what I’m doing ??
Also tried adding the cat parameter to the query post:
query_posts( $query_string . '&cat=17' );
But that didn’t work either.
Any help would be greatly appreciated!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘query Posts: Last 30 days & specific category – 50% working’ is closed to new replies.