0

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

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 ?>

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.