Issue My client has added their product titles in UPPERCASE, and as such the og:title property is also in uppercase.

For example: 'MY T SHIRT'

Current Code

<meta property="og:title" content="<?= $block->escapeHtmlAttr($block->stripTags($block->getProduct()->getName())) ?>" />

Desired Result: I want the title to be output in Propercase.

For example: 'My T Shirt'

Can anyone please suggest an update to the code to get this working as desired?

1 Answer 1


This issue isn't specific to Magento but can easily be fixed by using PHP's ucwords function.

ucwords will capitalize the first letter of each word while making the rest of the letters lowercase.

<meta property="og:title" content="<?= $block->escapeHtmlAttr($block->stripTags(ucwords($block->getProduct()->getName()))) ?>" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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