Embed WordPress blog content anywhere on your storefront with CMS widgets
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:
| Parameter | Admin label | Type | Default | Description |
|---|---|---|---|---|
post_ | Number of Posts | text | 5 | Number of posts to display |
show_ | Show Thumbnail | select | No | Show the featured image |
show_ | Show Date | select | Yes | Show the post date |
category_ | Category ID Filter | text | (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:
| Parameter | Admin label | Type | Default | Description |
|---|---|---|---|---|
post_ | Post ID | text | (none) | WordPress post ID to feature. Leave blank for the latest post |
category_ | Category Slug | text | (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:
| Parameter | Admin label | Type | Default | Description |
|---|---|---|---|---|
category_ | Category Slug | text | (none) | WordPress category slug. Leave blank for posts from all categories |
post_ | Number of Posts | text | 4 | Number of posts |
display_ | Layout | select | Grid | grid 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
- Edit a CMS page or block in Magento Admin
- Click Insert Widget in the page builder toolbar
- Select the widget type from the dropdown
- Configure the parameters
- Click Insert Widget to add the shortcode to the page content
Adding a Widget via Layout XML
<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
- Sidebar blocks for blog pages : categories, tags, archive, search and recent posts
- Override the widget templates in your theme
- Build a custom widget type