How to stop html showing when posting to Facebook

Hi Guys,
I just went to place a product to facebook by copying the URL for the product. I noticed that the heading Quick Overview appears with the html code showing either side of it http://prntscr.com/e85rk9 and http://prntscr.com/e85ryx
Is there a way to stop this or is there a way to hard code the heading into the template so it doesn’t have to be added in the html of the product?
 
Many thanks Jim

3 answers

Profile photo of Mall Staff 184060.00 $tone February 14, 2017
Public

Hi there,

Is there a way to stop this or is there a way to hard code the heading into the template so it doesn’t have to be added in the html of the product?

Yes, in your custom theme, you can make overwrite the template file at: vendor/magento/module-catalog/view/frontend/templates/product/view/opengraph/general.phtml
To exclude html tags, in your custom template file, you can change the code line:

<meta property="og:description" content="<?php echo $block->escapeHtml($block->getProduct()->getShortDescription()); ?>" />

to the code line:

<meta property="og:description" content="<?php echo $block->escapeHtml(strip_tags($block->getProduct()->getShortDescription())); ?>" />

Regards,
Mall.
 

#1

Please login or Register to Submit Answer

Written By

Comments