title: Adding UPC Attribute to Product Page
body: <p>I need to have an attribute &quot;UPC:&quot; displayed on my product pages when a UPC Number is entered in the backend. I need it to display just below the SKU#. I followed instructions from another post and by using their suggestion I was able to get the # to show in the right place, however the issue is the label UPC: is not showing just like the SKU: label does. Something is missing in the custom code. If anyone else has a better solution than I tried, I am willing to remove what I tried and start this from scratch.</p>
  <p>Below is the codes and files I used.</p>
  <p>You can display custom attributes by creating block after the sku block in catalog_product_view</p>
  <p>Create catalog_product_view.xml in &quot;app\design\frontend\VENDOR\THEME\Magento_Catalog\layout\catalog_product_view.xml&quot;</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot;?&gt;
  &lt;page layout=&quot;2columns-right&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View/Layout/etc/page_configuration.xsd&quot;&gt;
      &lt;body&gt;
          &lt;referenceContainer name=&quot;content&quot;&gt;
              &lt;block class=&quot;Magento\Catalog\Block\Product\View&quot; name=&quot;product_custom_attr&quot; template=&quot;Magento_Catalog::product/view/custom_attr.phtml&quot; after=&quot;-&quot;/&gt;
          &lt;/referenceContainer&gt;
          &lt;move element=&quot;product_custom_attr&quot; destination=&quot;product.info.stock.sku&quot; after=&quot;-&quot;/&gt;
      &lt;/body&gt;
  &lt;/page&gt;
  </code></pre>
  <p>Create custom_attr.phtml file in &quot;app\design\frontend\VENDOR\THEME\Magento_Catalog\templates\product\view\custom_attr.phtml&quot;</p>
  <pre><code>&lt;?php $_product = $this-&gt;getProduct(); ?&gt;&lt;div class=&quot;product attribute&quot;&gt;
  &lt;div class=&quot;value&quot;&gt;&lt;?php echo $_product-&gt;getData('upc_code') ?&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p><img src="https://i.stack.imgur.com/T0jE1.jpg" alt="enter image description here" /></p>