• Resolved mapdi

    (@mapdi)


    Hi there,

    Thanks for this great Plugin!

    Any chance to exclude a custom taxonomy from caching?

    E.g. with a filter?

    add_filter(
        'XXXXX_skip_cache',
        function() {
        	return (
    			has_term( array( 'term' ), 'new-taxonomy' ) ? true : false
        	);
        }
    );
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi!

    You can use the filter wpo_can_cache_page, or define the constant DONOTCACHEPAGE when the post has a term.

    e.g.

    
    add_action('init',
    	function() {
    		if (has_term( array( 'term' ), 'new-taxonomy' ) && !defined('DONOTCACHEPAGE')) {
    			define('DONOTCACHEPAGE', true);
    		}
    	}
    );
    

    or

    
    add_filter(
        'wpo_can_cache_page',
        function() {
        	return (
    			has_term( array( 'term' ), 'new-taxonomy' ) ? false : true
        	);
        }
    );
    

    Marc.

    • This reply was modified 5 years, 2 months ago by Marc Lacroix.

    Edit the hook should be wp, not init.

    add_action('wp',
    	function() {
    		if (has_term( array( 'term' ), 'new-taxonomy' ) && !defined('DONOTCACHEPAGE')) {
    			define('DONOTCACHEPAGE', true);
    		}
    	}
    );
    
    Thread Starter mapdi

    (@mapdi)

    Thanks. I’ll give it a try and come back to you.

    Thread Starter mapdi

    (@mapdi)

    @marcusig

    It works! Thank you so much. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude a custom taxonomy from caching’ is closed to new replies.