Are you one of the many WooCommerce users who have recently updated to version 7.7.0 and found an unexpected issue when trying to edit your products? If you’ve enabled the new block editor for WooCommerce products using custom code or a plugin since WooCommerce 7.6.1, you might have encountered the message “The content of your post doesn’t match the template assigned to your post type.”
On top of that, you may have also realized that adding new blocks has become impossible. If this has been your experience, you’re not alone, and we have solutions for you.
The Underlying Issue
The root of this problem lies in the recent addition of a template to the “product” post type. WooCommerce added this template along with a template lock, which could be clashing with your previous customization. This template lock is essentially a restraint that prevents you from modifying the layout of the product page.
Removing the Template
To get around this issue, one solution is to remove the template entirely. This can be done using a filter in your function file. Here’s how:
add_filter('woocommerce_register_post_type_product', function( $args ) {
unset( $args['template'] );
return $args;
});
By including this filter, the template will be removed, and you can go back to customizing your product pages as you wish.
Removing the Template Lock
Alternatively, you might want to keep the template but remove the template lock. This solution gives you the freedom to add new blocks to the template. You can accomplish this by using the following code in your function file:
function woo_product_gutenberg_template_remove_lock( $args ) {
$args['template_lock'] = false;
return $args;
}
add_filter( 'woocommerce_register_post_type_product', 'woo_product_gutenberg_template_remove_lock' );
This code will keep the new template for your products but remove the lock. This means it won’t restrict you when adding or changing blocks for both new and existing products.
Remember, when dealing with your function file, it’s crucial to create a backup before making any changes. If anything goes wrong, you can always revert to the backup.
We hope this helps you navigate through the changes brought by the WooCommerce 7.7.0 update. Stay tuned to Wooptimized for more tips and tricks to maximize your WooCommerce experience.