0

我已安装并运行 W3 Total Cache,但它在发布或更新帖子时无法正确刷新我的类别页面。我想自动执行此操作。

在我的 Wordpress 主题中,我有几个类别页面,它们的标题是 category-green-widgets、category-blue-widgets 等。

一些,例如category-widgets,可以引入category-red-widgets和category-blue-widgets(我是这样编码的)。因此,我需要转储所有类别,而不仅仅是帖子所属的类别。

首先,我认为这段代码可能会用于获取帖子的类别:

  /* Flush category pages */
    function category_cache_flush_on_post( $post_id ) {
        if(function_exists('w3tc_pgcache_flush_post')){
                $post_categories = wp_get_post_categories( $post_id );
                foreach($post_categories as $c)
            w3tc_pgcache_flush_post($c[0]);
        }

    }
    add_filter( 'save_post', 'category_cache_flush_on_post', 10, 1 );

那么如何在更新或发布时转储所有类别的缓存?W3TC 对此有何呼吁?

4

1 回答 1

1

on the page cache settings tab be sure that "Post terms pages" option is checked.

于 2015-03-25T14:15:43.647 回答