# What does `withRouting(wordpress: true)` do when booting Acorn 5?

**URL:** https://discourse.roots.io/t/what-does-withrouting-wordpress-true-do-when-booting-acorn-5/30055
**Category:** acorn
**Created:** 2025-11-22T01:00:13Z
**Posts:** 3

## Post 1 by @andronocean — 2025-11-22T01:00:13Z

I’m in the process of upgrading a site to Acorn 5. I’ve read all the docs on how to properly boot Acorn and register routes, and I’m confused by what’s going on in the `withRouting()` method.

Here’s the example given under **Advanced Booting** in [Installing Acorn in WordPress | Acorn Docs | Roots](https://roots.io/acorn/docs/installation/#advanced-booting:)

```
Application::configure()
	->withProviders([
		//...
	])
	->withRouting(
		web: base_path('routes/web.php'), // Laravel-style web routes
		api: base_path('routes/api.php'), // API routes
		wordpress: true // Enable WordPress request handling
	)
	->boot();
```

I understand the `web` parameter. I’m a little unclear about `api` (those are Laravel API routes, entirely separate from the WP REST API, right? — no authentication by default, but I can use [Laravel’s API stuff](https://laravel.com/docs/12.x/routing#api-routes) if I want?)

But I have no idea what `wordpress` does. The mentions of it I found in the docs and here on discourse only note that it’s necessary for Livewire to work.

Tracing the source just leads me to a method `Application->handleWordPressRequests()`. _What does this ultimately DO?_ Does it have side-effects? Does it change anything with query or template resolution?

---

## Post 2 by @rivanuff — 2025-11-24T14:45:21Z

Like the method implies, it allows you to handle WP requests with Laravel functionality like middleware.

An example would be adding CSP headers through the [GitHub - spatie/laravel-csp: Set content security policy headers in a Laravel app](https://github.com/spatie/laravel-csp) package and flashing GTM data with [https://github.com/spatie/laravel-googletagmanager](https://github.com/spatie/laravel-googletagmanager) .

```
<?php
use Roots\Acorn\Application;
use Roots\Acorn\Configuration\Middleware;
use Spatie\Csp\AddCspHeaders;
use Spatie\GoogleTagManager\GoogleTagManagerMiddleware;

add_action('after_setup_theme', function () {
    Application::configure()
        ->withProviders([
            //...
        ])
        ->withMiddleware(function (Middleware $middleware) {
            $middleware->append(AddCspHeaders::class);
            $middleware->append(GoogleTagManagerMiddleware::class);
        })
        ->withRouting(
            wordpress: true,
            web: base_path('routes/web.php'),
        )
        ->boot();
}, 0);
```

It doesn’t have any side effects, unless you implement something that adds some (like above) :slight_smile:

---

## Post 3 by @andronocean — 2025-11-24T19:58:06Z

Middleware! Of course :man_facepalming: Thank you, perfect examples… that could be very useful!
