【问题标题】:Managing RSS Cache with Simplepie fetch_feed()使用 Simplepie fetch_feed() 管理 RSS 缓存
【发布时间】:2010-10-12 15:03:38
【问题描述】:

如何在 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;
}

【问题讨论】:

    标签: rss simplepie


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多