Integrating Init Live Search with Headless WordPress or Static Sites

More and more websites are moving toward headless architectures (Next.js, Nuxt, Astro, etc.) or static site generators (Hugo, Eleventy) to maximize performance and SEO. One common challenge is building a fast, flexible search system—especially when most WordPress search plugins are bulky or don’t provide clean APIs.

Integrating Init Live Search with Headless WordPress or Static Sites

Init Live Search solves this problem by offering a clean, RESTful API that returns structured JSON—ready to be fetched from any frontend framework.

1. Why Init Live Search works great for Headless / Static Sites

  • Built entirely on the WordPress REST API.
  • Powered by Vanilla JavaScript (no jQuery).
  • Returns structured JSON including: title, type, url, thumb, date, excerpt, category, and more.
  • Easily fetchable from Next.js, Nuxt, Astro, Vue, React, mobile apps, PWAs, and beyond.

2. Basic search API fetch example

fetch('https://example.com/wp-json/initlise/v1/search?term=manga')
  .then(res => res.json())
  .then(data => console.log(data));

Available query parameters:

  • term: the keyword to search
  • exclude: post ID to exclude (optional)
  • page: pagination (default: 1)
  • post_types: optional list of post types (defaults from plugin settings)
  • Fallback behavior and max results are configured in the plugin admin

3. Calling slash commands from any frontend

fetch('https://example.com/wp-json/initlise/v1/recent')
  .then(res => res.json())
  .then(data => renderSearchResults(data));

You can also fetch other slash commands:

  • /date?value=2024/05
  • /tax?taxonomy=category&term=wordpress
  • /related?title=Page Title&exclude=123
  • /random, /read?ids=1,2,3
  • /product?on_sale=1&min_price=100

This gives you full flexibility for SPAs, static sites, and headless applications.

4. Easy-to-render JSON response

Each result object typically includes:

{
  title: "Post Title",
  type: "Post",
  url: "https://...",
  thumb: "https://...",
  date: "2024-05-23",
  excerpt: "...",
  category: "News"
}

Loop through the results and render them using your preferred UI framework—React, Vue, Svelte, etc.

5. Caching & Security Tips

  • The plugin internally caches each REST response for 5 minutes using wp_cache.
  • Use Cloudflare Cache Rules to additionally cache public endpoints like /recent, /tax, or /product.
  • For draft/private content, always fetch via a secure backend proxy to protect sensitive data.

6. Common API Endpoints

  • /search?term=keyword
  • /id/{id}
  • /recent
  • /date?value=YYYY/MM
  • /tax?taxonomy=category&term=slug
  • /related?title=example
  • /read?ids=1,2,3
  • /random
  • /taxonomies?taxonomy=category
  • /product?on_sale=1

Conclusion

Init Live Search isn’t just a WordPress plugin—it’s a full-featured search API engine optimized for modern frontend development.

REST-first, cache-ready, and easy to plug into your frontend or backend, it’s perfect for decoupled WordPress setups.

If you’re building a headless or static site, treat Init Live Search as a fast, modular, REST-powered search solution.

Comments


  • No comments yet.

Init Toolbox

Press Ctrl + \ on desktop, or swipe left anywhere on mobile.

Login