-
Hi there How can we use the woocommerce product description for seo description. I used this code %excerpt% to pull the data it’s gathering the data from short description not from the product description. I’m not using the short description always using product description. Please help me to get the way of it
Thanks and regard
Rafilathif- This topic was modified 5 years ago by Rafilathif.
-
Hello,
Thank you for contacting Rank Math today.
If you would like to use the product short description, kindly change the variable to %wc_shortdesc%
Looking forward to helping you. Thank you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
Thank you for contacting Rank Math today.
This will require a bit of customization since Rank Math will check if the short description exists first before loading the long description.
Here is a code snippet that you can use only on the frontend to load a custom description:/** * Allow changing the meta description sentence from within the theme. * * @param string $description The description sentence. */ add_filter( 'rank_math/frontend/description', function( $description ) { return $description; });
Looking forward to helping you. Thank you.
No i don’t want to use the short Description currently it’s taking the information from that. See this screenshot https://snipboard.io/FyruOM.jpg
I need to get this information from product description where is showing in front end under the Description tab see the screenshot https://snipboard.io/WNTElr.jpg
I can share with you my login Details If you want please check
you can check these products
https://supperkart.com/zain-sunflower-oil/
Added short description and Product Descriptionhttps://supperkart.com/omo-liquid-laundry-detergent/
Added only Product DescriptionI need to gather the SEO description from Product Description
Hello,
Thank you for contacting Rank Math today.
I have checked this post and https://supperkart.com/omo-liquid-laundry-detergent/ and the right description is generated from the product description as you can see below:
Removing the short description works as you can see above.
Looking forward to helping you. Thank you.
Yes it’s work But i don’t want to use the short description even i update short description for my product always i need to get from the product description how can i set that because currently i update the information to both and it’s taking from short description and i’m not updating the SEO optimized work to that
I’m looking like you refer me above for short description this %wc_shortdesc%
What is for Product descriptionThanks
Hello,
Thank you for contacting Rank Math today.
You can add the following code snippet to your theme’s functions.php file to get the long product description and add this to your meta description:
/** * Allow changing the meta description sentence from within the theme. * * @param string $description The description sentence. */ add_filter( 'rank_math/frontend/description', function( $description ) { global $post; if(is_singular( 'product' )){ $description = apply_filters( 'the_content', $post->post_content ); return '' !== $description ? wp_html_excerpt( $description, 156 ) : ''; } return $description; });
Looking forward to helping you. Thank you.
I Added the code like this https://snipboard.io/md6PnE.jpg and not work for me still it’s showing the short description Please check this https://snipboard.io/6KWjGn.jpg
And i have shared my login detail above if you can check my code in child theme functions.php
Thanks and regards
RafilathifHello,
Thanks for getting back to me, I am not sure why we never got a notification for this reply.
The code will only work on the frontend. Please inspect the page source on the single products and let us know how this goes.
Thank you.
So for the long description to be the preferred one that I have to put?
Hi there,
Thanks for the question.
Yes this code will generate a custom meta description on the frontend that will be extracted from the product long description.
I hope this info helps. Thank you.
Which code of the two you have published in this post? You should be more specific, it’s not very professional of you.
On the other hand, the last code mentions the content of the post ‘the_content’, $ post-> post_content, and what I want is for Google to take the product description of the long, not the short or the content of the post .
Be a little more professional, I have already asked this in other posts and they have not solved it and now in this other they put a little interest without finishing solving anything.
Or they improve, or this plugin will not be the future.
Hi there,
Thanks for the reply.
The first code on this thread is the bare bone filter without any customization while the second snippet shown below uses the global $post to get the long description from the current product. This is one of the ways to get the long description but you can also use the native WooCommerce API functions or the global $product to get the same value. The one below works on my end.
/** * Allow changing the meta description sentence from within the theme. * * @param string $description The description sentence. */ add_filter( 'rank_math/frontend/description', function( $description ) { global $post; if(is_singular( 'product' )){ $description = apply_filters( 'the_content', $post->post_content ); return '' !== $description ? wp_html_excerpt( $description, 156 ) : ''; } return $description; });
Please add it to your theme’s functions.php file and let me know how this goes. 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 ‘Using woocommerce rich snipt’ is closed to new replies.