URL Routing
The Controller/Router.php class implements Magento\Framework\App\RouterInterface and intercepts all requests matching the configured blog base path.
Route Resolution Order
Section titled “Route Resolution Order”The router tries each pattern in order. The first match wins.
| Pattern | Example URL | Controller | Action | Params |
|---|---|---|---|---|
| Blog listing | /blog | blog | index | - |
| Paginated listing | /blog/page/2 | blog | index | page=2 |
| Category archive | /blog/category/news | category | view | slug=news |
| Category paginated | /blog/category/news/page/2 | category | view | slug=news, page=2 |
| Tag archive | /blog/tag/magento | tag | view | slug=magento |
| Author archive | /blog/author/john | author | view | slug=john |
| Search | /blog/search | search | results | (query via GET) |
| Single post | /blog/my-post-slug | post | view | slug=my-post-slug |
The single-post catch-all pattern is always last. It matches any single path segment that does not match a more specific pattern above.
How the Router Works
Section titled “How the Router Works”public function match(RequestInterface $request): ?ActionInterface{ // 1. Check module is configured (URL + API key set) if (!$this->config->isConfigured()) { return null; }
// 2. Check URL starts with blog base path $identifier = trim($request->getPathInfo(), '/'); $basePath = $this->config->getBlogBaseUrl();
if (!str_starts_with($identifier, $basePath)) { return null; }
// 3. Resolve the remaining path segment $path = substr($identifier, strlen($basePath) + 1); $result = $this->resolveRoute($path);
// 4. Set request params and dispatch $request->setModuleName('wordpress'); $request->setControllerName($result['controller']); $request->setActionName($result['action']); // ...}Configurable Base Path
Section titled “Configurable Base Path”The base path is read from orangecollar_wordpress/blog/base_url in Magento system config. It defaults to blog but can be changed to any alphanumeric string (e.g., news, articles, journal).
If you change the base path, flush the Magento cache. Any hardcoded links in content must also be updated (or rely on the link rewriting in ContentProcessor).
Router sortOrder
Section titled “Router sortOrder”The WordPress router runs at sortOrder 25 in Magento’s router list. The standard Magento router list order is:
| sortOrder | Router |
|---|---|
| 10 | Admin |
| 20 | Robots/Sitemap |
| 25 | WordPress (this module) |
| 30 | Standard Magento URL rewrites |
| 100 | CMS |
| 200 | Default (404) |