Magento 2 WordPress Content Blocks DocumentationContent Blocks

« Back to Magento 2 WordPress - Content Blocks

  • Installation

    You can install the module for Magento 2 using Composer or you can manually install it using FTP.

    • Run the following commands in your Magento 2 root directory to install the module using Composer.

      # Add the FishPig Composer repo
      composer config repositories.fishpig composer https://repo.fishpig.co.uk/
          
      # Install the module using Composer
      composer require fishpig/magento2-wordpress-integration-contentblocks:*
      
      # Enable the module in Magento 2
      php bin/magento module:enable FishPig_WordPress_ContentBlocks
      
      # Run the Magento upgrade system
      php bin/magento setup:upgrade
    • You can download the latest version of the module from the Downloads page.

      Extract the ZIP file and upload the files to your Magento site at the directory below:

      app/code/FishPig/WordPress_ContentBlocks

      When creating the folders, ensure you use the correct capitalisation.

      To complete the installation, run the following commands in a terminal.

      # Enable the module in Magento 2
      php bin/magento module:enable FishPig_WordPress_ContentBlocks
      
      # Run the Magento upgrade system
      php bin/magento setup:upgrade

    ↑ Back to Top

  • Add a Content Block

    There are many ways to add content blocks from WordPress into your Magento website and all of them are easy.

    Shortcodes

    The easiest way to add a WordPress content block to your Magento website is to use the basic shortcode system that the module provides.

    This allows you to specify a content block by it's ID or identifier (this is the slug/post_name/url_key from WordPress).

    WordPress Content Block Shortcode by ID

    The ID can be found in the URL while editing the content block in the WordPress Admin.

    [wp_block id="1234"]

    WordPress Content Block Shortcode by Identifier

    In WordPress, the term 'slug' is used to determine the identifier for each content block and this works just like the url_key field in Magento. This can often be easier to remember than an ID.

    [wp_block identifier="promo-listing-01"]

    Widgets

    The module adds a handy widget to Magento so you can include a content block from the Admin anywhere you would include a widget.

    CMS Block Select/Dropdowns

    Various places in the Admin, you will see a dropdown allowing you to select a CMS block to be automatically injected into your Magento site. This dropdown will now also include WordPress content blocks so you can easily select a content block from WordPress instead.

    A great example of this is the category edit page as this allows you to select a CMS block for the category header. With Content Blocks installed, you can now generate your category header block from WordPress.

    ↑ Back to Top

  • Ideas

    The possibilities are endless with Content Blocks, but here's a few ideas to get you started.

    Category Header

    This ones easy. You can specify a content block using the CMS Block dropdown while editing a category. You can now design your category headers using Elementor and other WordPress plugins!

    Product Description

    Have you ever thought how cool it would be to build your product descriptions in WordPress? With Content Blocks, you can do this easily and create a dynamic system to do it.

    First, start create a new content block and use the product SKU as the URL slug (identifier) in WordPress. Next, you can either manually add the following to your product description field, or better yet, create a template to dynamically output it to the page so that it's picked up and converted into the block.

    [wp_block identifier="product-sku"]

    If you don't have mnay products, you could manually add this to the description field in the Admin. If you do have lots of products, edit the description template to dynamically output this shortcode.

    echo '[wp_block identifier="' . $block->escapeHtmlAttr($block->getProduct()->getSku()) . '"]';

    ↑ Back to Top

Want to Make Magento 2 Faster?

Make Magento 2 instantly faster by installing our industry recognised optimisation modules.

  • Full Page Cache

    Magento 2 Full Page Cache

    The fastest full page cache extension available for Magento 1 and Magento 2. It's even faster than the default Magento 2 FPC.

    £149
  • Page Speed

    Magento 2 Page Speed

    Automatically increase your page speed by optimising your content and assets.

    £149
  • Security Suite

    Magento 2 Security Suite

    Protect your site from spam, bots and hackers using this automated rule based security system.

    £129
  • Cache Warmer

    Magento 2 Cache Warmer

    Automatically request all URLs in your XML sitemap to pre warm your full page cache.

    £129