I'm trying to create a custom RSS feed that shows posts from the custom post type 'events' for the next 7 days ahead only.

The feed is already sorted by event start date order rather than published date through the plugin, I just can't figure out how (as a beginner in PHP!) how to limit the feed to only the 7 days ahead. This is the query I have so far, which works fine until I try to filter the feed against a date and then it returns no posts :-(

Any pointers much appreciated!

date = date("d-m-Y");
$date = strtotime($date);
$date = strtotime("+7 day", $date);

$args = array(
    'post_type' => 'event',
    'showposts' => 10,
    'meta_key' => 'st_date',
    'meta_type' => 'date',
    'value' => $date,
    'compare' => '<'

  • There aren't uquite enough details here. How exactly you are creating the feed? What plugin is involved in it? How are you trying to filter?
    – Rarst
    Aug 22, 2014 at 15:23
  • Hi Rarst, The feed is created using an RSS template I created from a tutorial. I know the feed template works fine as if I take the query down to just 'showposts' is works. It's just the more complex query I'm struggling with. The plugin is EventOrganiser. I'm 99% sure it's my query that's wrong more than anything else.... possibly date formats but I'm learning as I go here! :-)
    – JcG
    Aug 26, 2014 at 8:21


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.