I checked the HTML validator. But, the message is the following.

Quote " in attribute name. Probable cause: Matching quote missing somewhere earlier.

The meta description is automatic from the content. So, if the content includes the quotation, it is also included in meta descrption. I would like to strip the quotation.

Currently, I inserted the code in header.php as below.

$description = strip_shortcodes($description); 
$description = wp_strip_all_tags($description);

What should I add?


Try to use Yoast SEO: https://it.wordpress.org/plugins/wordpress-seo/

It's the best plugin for SEO in WP and should be strips all "dangerous" chars

  • Thank you for the info. But, at first, I'd like to try without plugin. Anyone else? – Yoos Oct 19 '18 at 9:16
  • In php you can use str_replace, for example: str_replace('"','',$metaDescription); or also use addslashes: php.net/manual/en/function.addslashes.php – ClodClod91 Oct 19 '18 at 9:25
  • Thank you for your reply, I tried $description = str_replace('"','',$description);, But, nothing changed. – Yoos Oct 19 '18 at 10:12
  • Moreover, I tried $description = htmlentities($description); code, the quotation was removed. But, it appeared " etc codes instead of the quotation.... – Yoos Oct 19 '18 at 10:18
  • See this: stackoverflow.com/questions/12111887/… – ClodClod91 Oct 19 '18 at 14:58

Probably, it works for HTML5 Validator.

$description = str_replace(array("\r\n","\r","\n"," ",'"',"'"),'',$description);

$description = strip_shortcodes($description);

$description = wp_strip_all_tags($description);

First quotation is removed, but second one is not removed, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.