SEO meta description length limit

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Viewing 1 reply thread
  • Author
    Posts
    • #129995
      AvatarOksana Grishchenko
      Participant

      Hello
      Can you please tell me how to implement meta description word limit to ensure good and consistent SEO in the product page. Admin should be able to control the number since it keeps changing as per google norms. We are talking about store–>product>seo , vendor can fill up meta description. Without the limit, site seo is impacted negatively.

    • #130314

      Hello,

      Add this js in your theme’s js file -(replace wordlen with your required word limit)

      if( $('.vendor-dashboard textarea#yoast_wpseo_metadesc').length > 0 ) {
          var wordLen = 10,
          len; // Maximum word length
          $('.vendor-dashboard textarea#yoast_wpseo_metadesc').keydown(function(event) {  
            len = $('.vendor-dashboard textarea#yoast_wpseo_metadesc').val().split(/[\s]+/);
            if (len.length > wordLen) { 
              if ( event.keyCode == 46 || event.keyCode == 8 ) {// Allow backspace and delete buttons
              } else if (event.keyCode < 48 || event.keyCode > 57 ) {//all other buttons
                event.preventDefault();
              }
            }
           
          });
        }

      And add this code n your theme’s functions.php –

      add_filter( 'body_class', function( $classes ) {
      	$userid = get_current_user_id();
      	if(wcfm_is_vendor($userid)) {
            $classes = array_merge( $classes, array( 'vendor-dashboard' ) );
      	}
      	return $classes;
      });

      Thanks.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.