Skip to content

Wordpress

Andreas Ekström edited this page Jul 11, 2026 · 4 revisions

Menus

Register WordPress menu positions in vitewp.config.ts:

export default defineConfig({
  wordpress: {
    menus: {
      primary: 'Primary menu',
      footer: 'Footer menu',
    },
  },
});

WordPress hooks in Astro

Astro templates can ask the internal WordPress runtime to render real WordPress actions and filters during SSR:

---
import { createHooks } from 'vite-wp/wordpress/hooks';

const hooks = createHooks(Astro.props);
const head = await hooks.action('wp_head');
const content = await hooks.filter('the_content', Astro.props.content);
---

<Fragment set:html={head.rendered} />
<article set:html={content.value} />

Blocks and plugin assets

ViteWP discovers block metadata from src/blocks/**/block.json and bundles WordPress-side JS/TS and optional CSS.

src/blocks/hero/block.json
src/blocks/hero/edit.tsx
src/blocks/hero/style.css # optional

Clone this wiki locally