Menu Close

The Content of your Post Doesn’t Match the Template Assigned to your Post Type Error in WooCommerce

You may have noticed that WooCommerce’s latest update to version 7.7.0 broke the ability to edit certain blocks in individual product pages and throws an error that ‘the content of your post doesn’t match the template assigned to your post type’. Apparently, WooCommerce has been under pressure to provide better native Glutenberg/blocks support for product management. As part of that effort to work with blocks, WooCommerce add a template to the product post type. Unfortunately, the update clashes with custom templates and locks down the editing. Fortunately, there is a workaround for this issue until WooCommerce can fix it properly. It’s a small snippet of code that unsets the new WooCommerce product post type template.

This snippet below needs to be copied and pasted into the child theme functions.php file.

/***********************************************************************
   May 26, 2023 - Masters of WordPress
	Known Issue with WooCommerce Blocks and Custom Templates Workaround
 ***********************************************************************/
add_filter('woocommerce_register_post_type_product', function( $args ) {
    unset( $args['template'] );
    return $args;
});