Last active
June 28, 2017 21:05
-
-
Save thagxt/d430dcb8fae3754c9dbc to your computer and use it in GitHub Desktop.
Custom RSS feed for WordPress with the latest updated posts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: RSS - Recently Updated | |
*/ | |
$args = array( | |
'post_type' => 'post', | |
'post_status' => 'publish', | |
'orderby' => 'modified', | |
'order' => 'DESC', | |
'ignore_sticky_posts' => '1', | |
'caller_get_posts' => 1 | |
); | |
$updated = new WP_Query($args); | |
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" | |
xmlns:content="http://purl.org/rss/1.0/modules/content/" | |
xmlns:wfw="http://wellformedweb.org/CommentAPI/" | |
xmlns:dc="http://purl.org/dc/elements/1.1/" | |
xmlns:atom="http://www.w3.org/2005/Atom" | |
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" | |
xmlns:slash="http://purl.org/rss/1.0/modules/slash/" | |
<?php do_action('rss2_ns'); ?>> | |
<channel> | |
<title><?php bloginfo_rss('name'); ?> - Recently Updated Feed</title> | |
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> | |
<link><?php bloginfo_rss('url') ?></link> | |
<description><?php bloginfo_rss('description') ?></description> | |
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('blog'), false); ?></lastBuildDate> | |
<language>en-US</language> | |
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod> | |
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency> | |
<?php do_action('rss2_head'); ?> | |
<?php | |
while($updated->have_posts()) : $updated->the_post(); | |
$product_img = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $isize ); | |
$getImg = $product_img[0]; | |
$today = current_time('Y-m-d'); | |
$pub = get_the_time('Y-m-d', $updated->ID); | |
$mod = get_the_modified_time('Y-m-d', $updated->ID); | |
$modIFTTT = get_the_modified_time('D, d M Y H:i:s +0000', $updated->ID); | |
if ( $pub !== $today && $mod === $today ) : | |
?> | |
<item> | |
<title><?php the_title_rss(); ?></title> | |
<link><?php the_permalink_rss(); ?></link> | |
<pubDate><?php echo $modIFTTT; ?></pubDate> | |
<dc:creator><?php the_author(); ?></dc:creator> | |
<guid isPermaLink="false"><?php the_guid(); ?></guid> | |
<description><![CDATA[<img src="<?php echo $getImg; ?>" width="250"><br> <?php the_excerpt_rss() ?>]]></description> | |
<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded> | |
<?php rss_enclosure(); ?> | |
<?php do_action('rss2_item'); ?> | |
</item> | |
<?php endif; endwhile; ?> | |
</channel> | |
</rss> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment