Tweak wp-rss2.php to show future-dated posts (events in future)
-
I am able to customize my theme to show future-dated events.
** How do I do this with the rss feed? I’m using feedburner, and want to set w-rss2.php to show new events too. It looks like it’s using The Loop, but the loop has customized tags like the_title_rss().
This is what wp-rss2.php currently has. (version 2.0.4)
<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
<item>
<title><?php the_title_rss() ?></title>
<link><?php permalink_single_rss() ?></link>
<comments><?php comments_link(); ?></comments>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
<dc:creator><?php the_author() ?></dc:creator>
<?php the_category_rss() ?>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<?php if (get_settings('rss_use_excerpt')) : ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php else : ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php if ( strlen( $post->post_content ) > 0 ) : ?>
<content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>
<?php else : ?>
<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
<?php endif; ?>
<?php endif; ?>
This is in my index.php.
<?php
$cat = 1; // the category id for calendar events
$postlimit = -1; // # of posts to display. -1 for all.
$now = date('Y-m-d H:i:s',(time() - 86400));
$future_posts = $wpdb->get_results("SELECT * FROM $wpdb->posts, $wpdb->post2cat WHERE category_id = '$cat' AND post_id = ID AND post_status='publish' AND post_date > '$now' ORDER BY post_date ASC LIMIT $postlimit");
if($future_posts) : foreach($future_posts as $post) :
setup_postdata($post);
?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
</div>
</div>
<div class="post_btm">
<small><p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></small>
</div>
<?php endforeach; ?>
Thanks in advance!
- The topic ‘Tweak wp-rss2.php to show future-dated posts (events in future)’ is closed to new replies.