Multiple object types | WordPress.org

[ad_1]

Hi @brunobragaw8t

Thank you for using our plugin!

We do not have support for multiple post types per cache record at this time. You could however achieve the same result with a simple filter where you clear the caches of posttype2 if posttype1 is saved (and the other way around):

add_filter( 'save_post', 'wprc_clear_caches_on_save', 10, 2 );

function wprc_clear_caches_on_save( $post_id, $post ) {
    if ( 'auto-draft' === $post->post_status || ! in_array( $post->post_type, [ 'postype1', 'posttype2' ] ) {
        return;
    }

    $post_type = ( 'posttype1' === $post->post_type ? 'posttype2' : 'posttype1' );
    $caching = \WP_Rest_Cache_Plugin\Includes\Caching\Caching::get_instance();
    $caching->delete_object_type_caches( $post_type  );
}

N.B. I typed this without testing it, so there may be some small errors in it, but the principle would remain the same.

Hi!

That’s actually exactly what we ended up doing in order to get around the issue.

Thanks for the reply anyway!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer