Theming and Templates
The module renders blog content using standard Magento layout XML and .phtml templates. Override them in your theme using Magento’s standard theme override mechanism.
Layout Handles
Each blog page type has a dedicated layout handle. See the Layout Handles reference for the full list.
Template Files
All default templates are in:
app/code/OCMLabs/WordPressIntegration/view/frontend/templates/
| Template | Purpose |
|---|---|
post/ | Post listing: blog home, category, tag and author archives, and search results |
post/ | Single post page. Renders the post title as the page’s only H1 |
post/ | SEO meta tags and JSON-LD in the page head |
post/ | Share buttons on post pages |
pagination.phtml | Pagination links on listings |
menu/ | WordPress navigation menu (horizontal) |
sidebar/ | WordPress menu in the blog sidebar (since 2.1.0) |
front-page.phtml | WordPress front page content on the blog home (since 2.1.0) |
widget/ | Recent posts widget |
widget/ | Featured post widget |
widget/ | Category posts widget |
sidebar/ | Sidebar categories |
sidebar/ | Sidebar tags |
sidebar/ | Sidebar archive |
sidebar/ | Sidebar search |
sidebar/ | Sidebar recent posts |
ViewModels
Three ViewModels are provided for use in templates:
Post ViewModel
OCMLabs\WordPressIntegration\ViewModel\Post
Provides helper methods for rendering a single post:
getPost(): Post- the current post data objectgetFormattedDate(Post $post): string- formatted publish dategetCanonicalUrl(Post $post): string- the Magento-side URL for the postgetCategoryUrl(Category $category): string- URL for a category archive
PostList ViewModel
OCMLabs\WordPressIntegration\ViewModel\PostList
Provides helper methods for listing pages:
getPosts(): array- array of Post objectsgetCurrentPage(): intgetTotalPages(): intgetPaginationUrl(int $page): string
Breadcrumbs ViewModel
OCMLabs\WordPressIntegration\ViewModel\Breadcrumbs
Used by BreadcrumbPlugin to build breadcrumb trails for all blog page types.
Overriding Templates
To override a template in your theme, copy it to:
app/design/frontend/Your/Theme/OCMLabs_WordPressIntegration/templates/
maintaining the same relative path as the original.
For example, to override the post view template:
app/design/frontend/Your/Theme/OCMLabs_WordPressIntegration/templates/post/view.phtml
Since 2.0.4, ocmlabs_post_view.xml removes Magento’s page.main.title block, so the heading in post/view.phtml is the only H1 on post pages. If you override post/view.phtml, keep the post title as an H1. If your theme adds a page title block back on ocmlabs_post_view, the page will have two H1s.
See also
Related pages
- Hyva templates if your store runs Hyva instead of Luma
- Extending the module with layout overrides, plugins and preferences
- Sidebar blocks that use these templates
- CMS widgets that use these templates