Skip to content

Extending the Module

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
...

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.xml

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>

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.

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.

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>

To add a new URL pattern (e.g., /blog/series/{slug}):

  1. Create a controller class in Controller/Series/View.php
  2. Add the route pattern to Router::resolveRoute() using a plugin or preference
  3. Create a layout handle file: view/frontend/layout/orangecollar_series_view.xml
  4. Create the template