{"id":104,"date":"2022-05-11T00:14:09","date_gmt":"2022-05-11T00:14:09","guid":{"rendered":"https:\/\/bslthemes.site\/vcard\/?p=104"},"modified":"2022-12-13T06:28:31","modified_gmt":"2022-12-13T06:28:31","slug":"how-to-show-custom-attribute-value-on-product-page-magento-2","status":"publish","type":"post","link":"https:\/\/atish.co.in\/?p=104","title":{"rendered":"How to show custom attribute value on product page magento 2"},"content":{"rendered":"<p>Create a phtml file location app\/design\/frontend\/vendor\/theme\/Magento_Catalog\/templates\/product\/view\/attr.phtml<\/p>\n<p>here using this php code.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-php\" data-lang=\"PHP\"><code>&lt;?php\r\n$objectManager = \\Magento\\Framework\\App\\ObjectManager::getInstance();\r\n$product = $objectManager-&gt;get('Magento\\Framework\\Registry')-&gt;registry('current_product');\r\necho $product-&gt;getResource()-&gt;getAttribute('style_tips')-&gt;getFrontend()-&gt;getValue($product);\r\n?&gt;<\/code><\/pre>\n<\/div>\n<p>Now upload xml code in <strong>catalog_product_view.xml<\/strong><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-xml\" data-lang=\"XML\"><code>&lt;referenceContainer name=\"product.info.main\"&gt;\r\n   &lt;block class=\"Magento\\Catalog\\Block\\Product\\View\" name=\"attr\" template=\"product\/view\/attr.phtml\" \/&gt;\r\n &lt;\/referenceContainer&gt;\r\nOR \r\n&lt;referenceContainer name=\"content\"&gt;\r\n   &lt;block class=\"Magento\\Catalog\\Block\\Product\\View\" name=\"attr\" template=\"product\/view\/attr.phtml\" after=\"product.info.media\" \/&gt;\r\n &lt;\/referenceContainer&gt;<\/code><\/pre>\n<\/div>\n<p>Now it will show your single product page<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create a phtml file location app\/design\/frontend\/vendor\/theme\/Magento_Catalog\/templates\/product\/view\/attr.phtml here using this php code. &lt;?php $objectManager = \\Magento\\Framework\\App\\ObjectManager::getInstance(); $product = $objectManager-&gt;get(&#8216;Magento\\Framework\\Registry&#8217;)-&gt;registry(&#8216;current_product&#8217;); echo $product-&gt;getResource()-&gt;getAttribute(&#8216;style_tips&#8217;)-&gt;getFrontend()-&gt;getValue($product);&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3,1],"tags":[24],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-magento","category-php","tag-magento2"],"acf":[],"_links":{"self":[{"href":"https:\/\/atish.co.in\/index.php?rest_route=\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atish.co.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atish.co.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atish.co.in\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atish.co.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=104"}],"version-history":[{"count":12,"href":"https:\/\/atish.co.in\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":430,"href":"https:\/\/atish.co.in\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions\/430"}],"wp:attachment":[{"href":"https:\/\/atish.co.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atish.co.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atish.co.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}