Is there a way to add a static block to the top of my product page, just beneath my navigation bar.
Thanks in advance.
You need to create one static block name product-topblock and set below content under the catalog_product_view.xml file,
Path is app/code/{Packagename}/{Modulename}/view/frontend/layout/catalog_product_view.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="page.top">
<block class="Magento\Cms\Block\Block" name="product-topblock" after="breadcrumbs">
<arguments>
<argument name="block_id" xsi:type="string">product-topblock</argument>
</arguments>
</block>
</referenceContainer>
</body>
</page>
Hi,
Thank you for your reply, I do not seem to have a catalog_product_view.xml
You need to create below file at your theme level,
app/design/frontend/{Packagename}/{themename}/Magento_Catalog/layout/catalog_product_view.xml
Hello @steven_banks
why not use easy way?
you can create widget for that and you can call block there.
More info
https://blog.landofcoder.com/add-cms-block-magento-2/
Hope it will help you.
if work then marks as a solution or give kudos.