How can i display an attribute under the title in magento 2.2.5
1 Answer
Add the snippet of code below to the following file in your custom theme:
Magento_Catalog/layout/catalog_product_view.xml
<referenceContainer name="columns.top">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.customattribute" template="Magento_Catalog::product/view/attribute.phtml" after="product.main.title">
<arguments>
<argument name="at_call" xsi:type="string">{at call goes here e.g. getCustomAtribute}</argument>
<argument name="at_code" xsi:type="string">{attribute code goes here}</argument>
<argument name="at_label" xsi:type="string">default</argument>
<argument name="add_attribute" xsi:type="string">itemprop="{attribute code goes here}"</argument>
</arguments>
</block>
</referenceContainer>
Then flush your caches and the attribute should appear.