-
Hi support team,
i use an automatic plugin for posts, it grab for description all the content in the post,
is there a Filter/Hook solution in RankMath to limit the description up to recommended characters?
Regards,
Stathis
-
Hello,
Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for the delay.
You can create your own custom variable and use it on your site like the code below. The code below will limit your content in the post to
150
characters. This should go in your theme’s functions.php file.Once done, you can use this
%limit_description%
variable on your post type and it will limit 150 characters for the description.I hope that helps. Thank you, and please don’t hesitate to contact us anytime if you need further assistance with anything else.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
Thank you for the follow-up.
It seems to be working fine on our end.
Could you please also check the post by editing and ensuring the variable
%limit_description%
is also applied there?I hope that helps.
Thank you, and looking forward to helping you.
Hi,
The variable %limit_description% is applied.
In my case it doesn’t work. Maybe because the description is has many paragraphs?
Please check the post.Can you please provide me the code for woocommerce products too?
Regards,
StathisHello,
Thank you for the follow-up, and apologies for the delay.
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.
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.
Thank you.
Hi,
thanks for your reply,
i paste the code to child functions.php file, then the variable at titles & meta / posts / Single Post Description,
It seems that it doesn’t work,
screenshots:
http://prntscr.com/12ruxx0
http://prntscr.com/12ruzhaany suggestions?
Regards,
StathisHello,
Thank you for contacting Rank Math again.
Could you please try using this code to limit the characters of your description and let us know if it works?
add_filter( 'rank_math/frontend/description', function( $description ) { if(is_single()){ return wp_html_excerpt($description, 150); } return $description; });
Note that the preview of the description will not work well on the editor but it should work fine on the front end. You may check your page source or test your post here
https://www.heymeta.com/
.Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Thank you.
Hi Brian,
this function working properly,
can you please provide a similar function for woocommerce single products?
Thank you very much for your support,
Regards,
StathisHello,
Thanks for your reply.
You can extend the condition in the code provided by my colleague to get the desired output:
add_filter( 'rank_math/frontend/description', function( $description ) { if(is_single() || is_product()){ return wp_html_excerpt($description, 150); } return $description; });
Please let us know how that goes.
Thank you.
Hi,
all working properly,
Thank you very much for your support,
Regards,
StathisHello,
We are super happy that this issue is already resolved. If you have any other questions in the future, know that we are here to help you.
If you don’t mind us asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.
The ticket ‘Filter/Hook to limit the description up to recommended characters’ is closed to new replies.