Extending the Module
Template Overrides
Section titled “Template Overrides”Override any template in your theme at the matching path:
app/design/frontend/Vendor/Theme/ OrangeCollar_WordPressIntegration/ templates/ blog/post/view.phtml blog/index.phtml sidebar/categories.phtml ...Layout XML Overrides
Section titled “Layout XML Overrides”Create layout files in your theme matching the blog layout handles:
app/design/frontend/Vendor/Theme/ OrangeCollar_WordPressIntegration/ layout/ orangecollar_blog_index.xml orangecollar_post_view.xmlCustom API Client Plugin
Section titled “Custom API Client Plugin”To intercept or modify API calls, create a plugin on ClientInterface:
class MyClientPlugin{ public function afterGetPosts( ClientInterface $subject, array $result, array $params = [] ): array { // Modify or log the result return $result; }}Register it in your module’s etc/di.xml:
<type name="OrangeCollar\WordPressIntegration\Model\Api\ClientInterface"> <plugin name="my_client_plugin" type="My\Module\Plugin\ClientPlugin" /></type>Custom Preference
Section titled “Custom Preference”To replace the API client entirely with your own implementation:
<preference for="OrangeCollar\WordPressIntegration\Model\Api\ClientInterface" type="My\Module\Model\Api\CustomClient" />Your class must implement all 18 methods in ClientInterface.
Custom Sidebar Block
Section titled “Custom Sidebar Block”Create a new block class extending the base:
class MyCustomSidebarBlock extends \Magento\Framework\View\Element\Template{ public function __construct( private readonly PostRepositoryInterface $postRepository, Template\Context $context, array $data = [] ) { parent::__construct($context, $data); }
public function getFeaturedPosts(): array { return $this->postRepository->getByCategory('featured', 1); }}Add it to any blog layout handle via layout XML.
Custom Widget Type
Section titled “Custom Widget Type”Declare a new widget in etc/widget.xml:
<widget id="my_custom_wp_widget" class="My\Module\Block\Widget\Custom" is_email_compatible="false"> <label translate="true">My Custom WordPress Widget</label> <description translate="true">Displays custom WordPress content</description> <parameters> <parameter name="count" xsi:type="text" visible="true" required="false" sort_order="10"> <label translate="true">Item Count</label> <value>5</value> </parameter> </parameters></widget>Adding a New Blog Page Type
Section titled “Adding a New Blog Page Type”To add a new URL pattern (e.g., /blog/series/{slug}):
- Create a controller class in
Controller/Series/View.php - Add the route pattern to
Router::resolveRoute()using a plugin or preference - Create a layout handle file:
view/frontend/layout/orangecollar_series_view.xml - Create the template