Hello @dimail,
Thank you for your query and we are so sorry about the trouble this must have caused.
Please note that this is the order we follow to generate meta descriptions for WooCommerce product:
1. Content from SEO Description field
If that is missing, then:
2. WooCommerce Excerpt or Product Short Description
If that is missing, then:
3. Template From General Settings in WordPress Dashboard > Rank Math > Titles & Meta > Products
If that is missing, then:
4. Auto generated Content from the product page
To force the use of the description you have set in Global product settings (Rank math > Titles & meta) you can add the following filter to your active theme’s functions.php file:
/** * Use the Description from Global Setting, if the description is missing in the Post metabox */ add_action( 'rank_math/frontend/description', function( $description ) { global $post; $desc = RankMath\Post::get_meta( 'description', $post->ID ); if ( is_product()) { $desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" ); if ( $desc ) { return RankMath\Helper::replace_vars( $desc, $post ); } } return $description; });
You may refer to this guide on how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Thread Starter
dimail
(@dimail)
I found this filter:
add_action( 'rank_math/frontend/description', function( $generated ) { if ( ! is_product() ) { return $generated; } global $post; $desc = RankMath\Helper::get_settings( "titles.pt_product_description" ); $desc = RankMath\Helper::replace_vars( $desc, $post ); return empty( $desc ) ? $generated : $desc; });
it is different from yours, what is the difference between them?
Hello @dimail,
In programming, often there are multiple ways to get the same output and that is the case here.
We would suggest using the one we shared in our initial response which we just tested now to be working properly.
Thank you.
Glad that helped, @dimail!
Don’t hesitate to get in touch if you have any other questions.
Thread Starter
dimail
(@dimail)
it is necessary that the global description be applied to all products, regardless of whether the product has a description or not.
Hello @dimail,
Yes, the filter we previously shared will apply to all your products even if they don’t have short or long descriptions.
Looking forward to helping you.