I am using a static front page for my blog to which I have added a widgetized sidebar area to hold an RSS feed widget. I want to show summaries of the latest two or three blog posts on the front page, but I am having problems with the RSS widget not updating.
For example, within the RSS widget set-up field, the RSS field is similar to “http://exampleblog.com/feed/”. The RSS feed will publish on the first refresh after activating the widget, but will not publish with subsequent newer posts. It doesn’t update with new posts.
One of the questions of this site attributed a similar problem to caching, and I am using WP Cache on the web server. De-activating WP Cache does not help.
I feel like I am missing some simple procedure, but find no mention in the Codex or this site.
Better to use a query loop to show posts, which is a modifed version of the main WP loop. This query loop won’t interfere with the main WP loop and can be used mutiple times in a sidebar or post/page with php execution enabled. Use a php widget in your sidebar: WordPress › PHP Code Widget « WordPress Plugins
Change mycategory to the name of a category, or remove to show all. And change showposts to the number of posts you want, or -1 to show all. You will have to CSS style the output.
<?php $my_query = new WP_Query('category_name=mycategory&showposts=1'); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"> <?php the_title(); ?></a> <?php the_excerpt(); ?> <?php endwhile; ?>
Also see The Loop « WordPress Codex and Function Reference/WP Query « WordPress Codex
The reason it doesn’t update is that
fetch_feed() function has its own transient-based caching that defaults to 12 hours.
You can filter cache lifetime value (globally or for specific feed URL) at
wp_feed_cache_transient_lifetime filter, but for own content it’s indeed better to access data directly than go through RSS.
If you don’t want to code this yourself – try Query Posts plugin.