Improve WooCommerce Google Feed Products Title with YOAST SEO

Some of you may use the popular YOAST SEO plugin with WooCommerce to improve your search results in Google. And some of you also use our Google Product Feed plugin.

But, the problem is that Google Product Feed doesn’t use YOAST SEO titles but WordPress products default titles. This has main issues. The first one is that your title aren’t optimized for SEO purposes, and the second one is that you can have encoding issues.

<?php
function lw_woocommerce_gpf_title($title, $product_id) {
	return get_post_meta( $product_id, '_yoast_wpseo_title', true );
}
add_filter( 'woocommerce_gpf_title', 'lw_woocommerce_gpf_title', 10, 2);

The good news is that with a simple snippet you can decide to use YOAST SEO product titles instead of default product titles. It’s pretty simple, all you have to do is to add this little snippet in the file called functions.php in your theme’s folder and BOOM!