RSS feed date
-
I have made a custom RSS feed.
<?php $postCount = 6; $posts = query_posts( 'showposts='.$postCount. '&category_name= mail' ); header('Content-Type: '.feed_content_type('rss-http').'; charset='.get_option('blog_charset'), true); echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> <rss version="2.0"> <channel> <title><?php bloginfo_rss('name'); ?> - Feed</title> <link><?php bloginfo_rss('url') ?></link> <description><?php bloginfo_rss('description') ?></description> <?php while(have_posts()) : the_post(); ?> <item> <title><?php the_title_rss(); ?></title> <guid isPermaLink="true"><?php the_guid(); ?></guid> <?php if (has_post_thumbnail( $post->ID ) ): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?> <enclosure url="<?php echo $image[0]; ?>" type="image/jpeg" /> <?php endif; ?> <pubDate><?php echo mysql2date('D, d M Y H:i:s', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> </item> <?php endwhile; ?> <?php wp_reset_query(); ?> </channel> </rss>
and i want the last 7 days of posts with category mail.
i have tryed this one and it works on site.com/feed/ but not on site.com/feed/admin/
function wpse334869_filter_feed( $query ) { if( $query->is_feed('admin') ) { $query->set( 'date_query', array( array( 'after' => '7 days ago' ) ) ); } } add_action( 'pre_get_posts', 'wpse334869_filter_feed' );
How can i do this?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘RSS feed date’ is closed to new replies.