OCMLABS/MODULE-WORDPRESS · WIDGETS

Embed WordPress blog content anywhere on your storefront with CMS widgets

  • Magento
  • Adobe Commerce
  • Hyvä

The module provides three CMS widgets for embedding WordPress content in any Magento CMS page, block, or layout position.

Available Widgets

Recent Posts Widget

Displays a list of the most recent blog posts. In the widget list it is WordPress Recent Posts.

Widget type identifier: OCMLabs\WordPressIntegration\Block\Widget\RecentPosts

Parameters:

ParameterAdmin labelTypeDefaultDescription
post_countNumber of Poststext5Number of posts to display
show_thumbnailShow ThumbnailselectNoShow the featured image
show_dateShow DateselectYesShow the post date
category_filterCategory ID Filtertext(none)Only show posts from this WordPress category ID. Leave blank for all categories

Featured Post Widget

Displays a single highlighted post with its featured image, title and excerpt. In the widget list it is WordPress Featured Post.

Widget type identifier: OCMLabs\WordPressIntegration\Block\Widget\FeaturedPost

Parameters:

ParameterAdmin labelTypeDefaultDescription
post_idPost IDtext(none)WordPress post ID to feature. Leave blank for the latest post
category_slugCategory Slugtext(none)Show the latest post from this category. Used only when Post ID is blank

If neither is set, the widget shows the latest post.

Category Posts Widget

Displays posts from a WordPress category in a grid or list layout. In the widget list it is WordPress Category Posts.

Widget type identifier: OCMLabs\WordPressIntegration\Block\Widget\CategoryPosts

Parameters:

ParameterAdmin labelTypeDefaultDescription
category_slugCategory Slugtext(none)WordPress category slug. Leave blank for posts from all categories
post_countNumber of Poststext4Number of posts
display_layoutLayoutselectGridgrid or list

Caching

Since 2.0.3, the widgets carry WordPress cache tags, so the full page cache entry of any page that shows a widget (including CMS pages) is purged when a listed post changes in WordPress. See Cache Tags.

Adding a Widget in CMS Editor

  1. Edit a CMS page or block in Magento Admin
  2. Click Insert Widget in the page builder toolbar
  3. Select the widget type from the dropdown
  4. Configure the parameters
  5. Click Insert Widget to add the shortcode to the page content
How-to: WordPress posts on the Magento homepage, 1:02

Adding a Widget via Layout XML

XML LAYOUT
<referenceContainer name="sidebar.main">
    <block class="OCMLabs\WordPressIntegration\Block\Widget\RecentPosts"
           name="wordpress.recent.posts"
           template="OCMLabs_WordPressIntegration::widget/recent-posts.phtml">
        <arguments>
            <argument name="post_count" xsi:type="string">5</argument>
            <argument name="show_thumbnail" xsi:type="string">1</argument>
            <argument name="show_date" xsi:type="string">1</argument>
        </arguments>
    </block>
</referenceContainer>

See also

Related pages

In this module