1

rss文件更新后如何强制刷新?无论如何,它似乎都在缓存...

提要位于 WordPress 仪表板小部件中,使用 simplepie fetch_feed() 方法...

/* Dashboard Widget */
function my_dashboard_widget_function() { 
    $rss = fetch_feed( "http://mysite.com/feed.rss" );

     if ( is_wp_error($rss) ) {
          if ( is_admin() || current_user_can('manage_options') ) {
               echo '<p>';
               printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
               echo '</p>';
          }
     return;
}
4

1 回答 1

0

add_filter('wp_feed_cache_transient_lifetime', create_function('$a', 'return 3600;'));

//其中 3600 是以秒为单位的缓存持续时间。

于 2010-10-21T18:19:50.897 回答