I am using custom theme inherit from blank theme, i want to display my attribute on product page above title, how to do that?
1 Answer
in catalog_product_view.xml
<move element="page.main.title" destination="content" before="-"/>
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Product\View" name="product.before.title" template="Magento_Catalog::product/view/before_title.phtml" before="-"/>
</referenceContainer>
and then create your Phtml : Magento_Catalog/templates/product/view/before_title.html
<?php
/**
* Product view template
*
* @var $block \Magento\Catalog\Block\Product\View
*/
$_product = $block->getProduct();
$custom = $_product->getData('custom_attribute');
?>
<?= $custom ?>