-
I’ve created the rank-math.php file and pasted the code provided in the following article. However, that didn’t resolve the issue. It is still giving more priority to the short description than the regular product description.
https://rankmath.com/kb/how-to-set-product-meta-description/
Do I have to do something else for the changes to take effect?
Please advise.
Thanks,
Kashif.
-
Hello,
We apologize for the issue you are facing with the product SEO description showing the short description instead of the regular product description. Thank you for raising this concern.
If you’ve already added the code snippet as mentioned in the article, ensure that you have updated the file correctly by clicking the Update File button after pasting the code. Here’s a reminder of what to check:
- Clear Cache: If you are using any caching plugins, clear the cache to ensure that the changes take effect.
- Check for Conflicts: Sometimes, other plugins or themes may conflict with Rank Math. Try disabling other plugins temporarily to see if that resolves the issue.
- Recheck Code: Make sure that the code snippet is correctly placed in the
rank-math.php
file without any syntax errors. - Reindexing: After making changes, it might take some time for Google to reindex your pages. You can also manually request indexing through Google Search Console.
If you have checked all these and the issue persists, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further.
We appreciate your patience and understanding!
Sources:
Using Variables in the SEO Title and Description » Rank Math
Google Shows A Different Meta Title/Description For My Site » Rank MathI’ve the correct code in rank-math.php in directory /public_html/wp-content/themes/woodmart/. I’ve also added %excerpt% in the field named Single Product Description under Products. However, in Rank Math SEO section on each products page I’m still seeing short description and not the product description.
Is there anything else that needs to be done to see the changes in Rank Math SEO section on Product’s page?
Hello,
Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.
The filter code shared on the KB is used to apply the description added in the Titles & Meta settings. This is the order we follow to generate meta descriptions for WooCommerce products:
1. Content from the 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 (long description)However, if you want to use the long description (product description) as your meta description then you’ll have to create a custom variable for the product’s long description by adding this filter on your site:
add_action( 'rank_math/vars/register_extra_replacements', function() { rank_math_register_var_replacement( 'woo_full_desc', [ 'name' => esc_html__( 'Woo Full Desc.', 'rank-math' ), 'description' => esc_html__( 'Woo Full Description...', 'rank-math' ), 'variable' => 'woo_full_desc', 'example' => woo_full_desc_callback(), ], 'woo_full_desc_callback' ); } ); function woo_full_desc_callback() { global $post; if ( empty( $post ) ) { return 'Product Description'; } return wp_strip_all_tags( $post->post_content ); }
Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
After this, you can use the
%woo_full_desc%
variable in the SEO description or single product description field.Please note that the filter may not be visible while editing the products as it only works when your products load in a browser. You can check the published/saved product’s meta description via its source code.
Let us know how it goes. Looking forward to helping you.
Thank you.
Thanks for providing that solution. However, we have around 500 product listings. Opening each one of them and adding %woo_full_desc% variable will be very difficult, if not impossible. Is there any other solution that uses Global settings instead of individual product settings?
Please advise.
Thanks,
Kashif.
Hello,
You can apply the shortcode globally by adding
%woo_full_desc%
in the Single Product Description field in Rank Math > Titles & Meta > Products.However, you will have to force the global settings to take precedence instead of following the default behavior of the plugin. Please also add the following filter on your website:
/** * 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; });
Don’t hesitate to get in touch if you have any other questions.
I’ve added the following code to the rank-math.php file and the %woo_full_desc% variable in Rank Math SEO > Titles & Meta > Products > Single Product Description field. However, the description in the Rank Math SEO section on the Product page is still showing short description.
/** * Use the Description from Global Setting, if the description is missing in the Post metabox */ add_action( 'rank_math/vars/register_extra_replacements', function() { rank_math_register_var_replacement( 'woo_full_desc', [ 'name' => esc_html__( 'Woo Full Desc.', 'rank-math' ), 'description' => esc_html__( 'Woo Full Description...', 'rank-math' ), 'variable' => 'woo_full_desc', 'example' => woo_full_desc_callback(), ], 'woo_full_desc_callback' ); } ); function woo_full_desc_callback() { global $post; if ( empty( $post ) ) { return 'Product Description'; } return wp_strip_all_tags( $post->post_content ); } 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; });
Hello,
In this case, we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
Please do take a complete backup of your website before sharing the information with us.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
We really look forward to helping you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
We can confirm that the full product description is used on your product pages, however, as we stated earlier the filter will not be visible while editing the products as it only works when your products load in a browser. You can check the published/saved product’s meta description via its source code.
For ease, you can use our Meta tag analyzer to check: https://rankmath.com/tools/meta-tag-analyzer/
Here’s an example:
We hope this helps. Please let us know if you have further questions or concerns.
Thank you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.
The ticket ‘Product SEO Description Is Showing Short Description And Not Product Description’ is closed to new replies.