Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
I

inertia-wordpress

> 编程语言
Open source

The WordPress adapter for Inertia.js.

182 stars0 likes1 views
WebsiteGitHub

About

The WordPress adapter for Inertia.js.

Inertia.js WordPress Adapter

The unofficial Inertia.js server-side adapter for WordPress.

Installation

Option 1: Install the package via composer. (Recommended)

composer require boxybird/inertia-wordpress

Option 2: Clone or download as a plugin and run composer install before activating in WordPress Admin.

Bare-bones Example Theme

  • https://github.com/boxybird/wordpress-inertia-starter-theme

Example Movie CPT WordPress Project

  • Demo: https://wp-inertia.andrewrhyand.com
  • Theme: https://github.com/boxybird/wordpress-inertia-demo-theme

Inertia Docs

  • Links: https://inertiajs.com/links
  • Pages: https://inertiajs.com/pages
  • Requests: https://inertiajs.com/requests
  • Shared Data: https://inertiajs.com/shared-data
  • Asset Versioning: https://inertiajs.com/asset-versioning
  • Partial Reloads: https://inertiajs.com/partial-reloads

Root Template Example

Location: /wp-content/themes/your-theme/app.php

php

    
        
        
        
    
    

         // Adds Inertia to the page

        
    

Root Template File Override

Location: /wp-content/themes/your-theme/functions.php

By default the WordPress adapter will use the app.php from .../your-theme/app.php. If you would like to use a different file name, you can change it. E.g. .../your-theme/layout.php.

php

Inertia Response Examples

Basic

Location: /wp-content/themes/your-theme/index.php

php
 $wp_query->posts,
]);

Less Basic

Location: /wp-content/themes/your-theme/index.php

This may look busy, however it can be thought of as a "Controller". It gives you a place to handle all your business logic. Leaving your Javacript files easier to reason about.

…

Quick Note

You may be wondering what this moster line above does:

php
'content' => apply_filters('the_content', get_the_content(null, false, $post->ID));

Because we can't use the WordPress function the_content() outside of a traditional theme template setup, we need to use get_the_content() instead. However, we first need to apply the filters other plugins and WordPress have registered.

Matter of fact, we can't use any WordPress function that uses echo, and not return.

But don't fret. WordPress typically offers a solution to this caveat: get_the_title() vs the_title(), get_the_ID() vs the_ID(), and so on...

Reference: https://developer.wordpress.org/reference/functions/

Shared data

Location: /wp-content/themes/your-theme/functions.php

…

Asset Versioning

Location: /wp-content/themes/your-theme/functions.php

Optional, but helps with cache busting.

php
add_action('init', function () {
    // If you're using Laravel Mix, you can
    // use the mix-manifest.json for this.
    $version = md5_file(get_stylesheet_directory() . '/mix-manifest.json');

    Inertia::version($version);
});

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHP

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言