Pono Press

  • Tutu – Block Theme
  • Plugins
  • Guides
  • Support
  • Blog

Get Started
  • How to Add Custom Attributes (Author, Category, Tags) to the Index and Show Them?

    Why add custom attributes?

    Search is often more than just finding words in a title or content. In real-world sites, users want to search by categories, see who wrote a post, or even browse by tags. That’s why extending the search index with custom attributes is so valuable — it makes results richer and more useful.

    In fact, one of our users recently asked for this feature on the WordPress.org support forums: How to add custom attributes (author, category) to the index?. That discussion inspired us to write this guide and show exactly how you can do it using the new yuto_modify_documents_data hook in Yuto Search.

    Step 1: Enqueue Your Custom JavaScript File

    Since Yuto Search exposes WordPress-style JavaScript hooks, the first step is to load your own JS file into the admin so you can hook into them. You’ll do this by enqueuing a custom script in your plugin or theme.

    Here’s an example in PHP:

    Once this is enqueued, you’re ready to start writing JavaScript that interacts with Yuto’s indexing process.

    Step 2: Write the Hook in JavaScript

    Now that your custom-admin-scripts.js file is loaded into the admin, you can use WordPress’ JS hooks to modify the data before it’s sent to Meilisearch. The new filter yuto_modify_documents_data introduced in 0.1.3 lets you add or change attributes for each document being indexed.

    Since you want the result to be searchable by categories, you need to add it to the searchable attributes using the hook yuto_searchable_attributes

    Here’s a simple example that adds the categories of a post:

    Step 3: Re-index Your Data

    Because the hook runs inside the WordPress admin, it only affects the data at the moment a post is indexed (on save, update, or delete). That means your existing content won’t magically get the new attributes—you’ll need to re-index it.

    👉 After re-indexing, head over to your Meilisearch dashboard (or use the API) to confirm that your documents now contain the new fields.

    Step 4: Show Custom Attributes in Frontend Search Results

    Once your documents are re-indexed with the new attributes, the next step is to display them in your search results. You can customize the item templates to include categories, tags, or author names.

    This JS file don’t need to be enqueued on the admin. You can enqueue like any normal frontend JS file.

    Here’s a simple example for it:

    With this final step, your search results are now fully enriched, showing categories custom attribute you added via the hook. You can do the same for other attributes like: tags, authors and more.

    Summary

    By using the new yuto_modify_documents_data hook, you can easily enrich your Meilisearch index with custom attributes like author names, categories, tags, or any other metadata. The process is simple:

    1. Enqueue a custom JS file in the admin with wp-hooks and wp-api-fetch dependencies.
    2. Write a hook in JS to modify the document data before it’s indexed.
    3. Re-index your content so existing posts include the new attributes.
    4. Customize your frontend templates to display the enriched data in search results.

    This approach gives you full control over your search data, enabling more meaningful results, and a richer user experience. Whether you want users to see authors, search by category, or explore tags, Yuto makes it easy to extend the index exactly the way your site needs.

    ponopress

    August 22, 2025
    Tutorials, Yuto
    meiliesearch, tutorials, update, yuto
  • 🎉 Yuto 0.1.1 Released – Shortcode & Elementor Support Now Available!

    🎉 Yuto 0.1.1 Released – Shortcode & Elementor Support Now Available!

    We’re excited to announce the release of Yuto version 0.1.1, and it comes packed with powerful new features that make integrating lightning-fast Meilisearch into your WordPress site easier than ever.

    Whether you’re using the Classic Editor, Elementor, or any other site builder, Yuto now fits seamlessly into your workflow.

    ✨ What’s New in 0.1.1

    You can now render the Yuto Autocomplete search anywhere on your site using the [yuto_autocomplete] shortcode. It’s perfect for sites that don’t use the Site Editor or prefer working in the Classic Editor, widgets, or page builders.

    Example Usage:

    [yuto_autocomplete]

    With Custom Options:

    [yuto_autocomplete enabled_indices="post,page" placeholder="Search..." auto_focus="true" open_on_focus="true" results_panel_placement="full-width"]

    Available Attributes

    You can read about the available attributes for the shortcode detailed in the Shortcode Documentation.

    PHP Example:

    echo do_shortcode('[yuto_autocomplete]');

    This makes it easy to include search in your theme header, sidebar, or anywhere you want!

    Elementor Integration via Shortcode

    Yuto now works beautifully inside Elementor using the Shortcode widget. No custom block or addon required.

    How to Use:

    1. Open your page in Elementor.
    2. Drag the Shortcode widget where you want to add search.
    3. Enter [yuto_autocomplete] in the input field.
    4. Update the page — done!

    This is perfect for adding search boxes in Elementor-built headers, product pages, or landing pages.

    Why This Matters?

    • No Block Editor? No Problem. You can now use Yuto’s powerful search even if your site uses the Classic Editor or other builders.
    • Maximum Flexibility. Developers and site builders can render search in templates, sidebars, headers, or anywhere using do_shortcode().
    • Easy Integration. Elementor users can integrate Yuto in seconds using the native Shortcode widget.

    Be sure to check out the new features and streamline your WordPress management tasks with Yuto!

    ponopress

    June 9, 2025
    Announcement, Yuto
    meiliesearch, update, yuto
  • Yuto Plugin Release 0.1.0: Introducing WP-CLI Support 🖥️

    Yuto Plugin Release 0.1.0: Introducing WP-CLI Support 🖥️

    We are excited to announce the release of Yuto Plugin version 0.1.0, which now includes support for WP-CLI! 🎉 For those unfamiliar, WP-CLI is a powerful command-line interface for managing WordPress installations, making it an essential tool for developers and administrators looking to streamline their workflow.

    What’s New?

    With this integration, Yuto empowers users to efficiently perform various tasks directly from the command line, such as indexing and deletion. This enhancement not only improves productivity but also opens up new possibilities for automation, allowing seamless execution of commands in scripts and integration with other automation tools. 🛠️

    WP-CLI Command Details

    Yuto introduces the following WP-CLI commands:

    NAME

    wp yuto

    DESCRIPTION

    Yuto CLI Commands.

    SYNOPSIS

    wp yuto

    OPTIONS

    • <action>: Action to perform. Options include:
      • build-index
      • delete-index
      • add-documents
    • <post-type>: Specify the post type to act upon.
    • [--ids=]: A comma-separated list of post IDs to index (only for add-documents).

    EXAMPLES

    Here are some examples of how to use the new commands:

    Build an index for a specific post type:

    wp yuto build-index post_type
    

    Delete the index for a specific post type:

    wp yuto delete-index post_type

    Add documents to the index for a specific post type:

    wp yuto add-documents post_type --ids=1,2,3

    Delete documents from the index for a specific post type:

    wp yuto delete-documents post_type --ids=1,2,3
    

    The addition of WP-CLI support in Yuto Plugin version 0.1.0 significantly enhances its functionality, providing developers and administrators with the tools they need to manage their WordPress sites more effectively. Whether you’re looking to index documents or delete documents from Meilisearch, Yuto’s CLI commands make it easier than ever to automate your workflow. 🌟

    Be sure to check out the new features and streamline your WordPress management tasks with Yuto!

    ponopress

    March 2, 2025
    Announcement, Yuto
    meiliesearch, update, yuto
  • Increasing Batch Size for Faster Performance 🚀

    Increasing Batch Size for Faster Performance 🚀

    Why Increase the Batch Size?

    If you have a large number of posts, pages, or custom post types that need indexing, the process can take significant time. Increasing the batch size can help reduce indexing time by processing more documents per batch.

    By default, Yuto indexes up to 999 documents per batch because larger batches process faster than smaller ones. For example, indexing 100,000 documents in 2 batches of 50,000 is much quicker than using 4 batches of 25,000. However, Meilisearch limits the maximum payload size to 100MB, which is why the default batch size is set to 999.

    Enqueuing the JavaScript File for the Yuto Settings Page

    To apply these changes, you need to enqueue the JavaScript file containing the hooks on the Yuto settings page.

    How to Increase the Batch Size

    Starting from version 0.0.7, you can increase the batch size using the yuto_index_batch_size hook. This hook accepts two parameters:

    Parameters:

    • batchSize (Integer) – Defines the batch size. Default: 999
    • UID (String) – The index ID.

    Example Usage:

    Important Note:

    Re-indexing is necessary for the changes made through this hook to take effect.

    Increasing Beyond 999: Adjusting the REST API Limit

    By default, the WordPress REST API restricts per_page to 100 posts per request. Yuto increases this limit to 999 for all post types. If you want to use a batch size higher than 999, you must first adjust the REST API’s per_page limit.

    Adjusting the REST API per_page Limit

    Use the rest_{$post_type}_collection_params filter to increase the maximum per_page value.

    Once this change is applied, you can use a batch size greater than 999 within the yuto_index_batch_size hook.

    Summary

    • The default batch size is 999, but it can be increased using the yuto_index_batch_size hook.
    • To exceed 999, update the WordPress REST API’s per_page limit.
    • Ensure that JavaScript hooks are properly enqueued on the Yuto settings page.
    • Ensure to Index the documents again for the changes to take effect.

    By following these steps, you can optimize your indexing process for better performance in Yuto. 🚀

    ponopress

    January 29, 2025
    Tutorials, Yuto
    meiliesearch, tutorials, update, yuto

Looking for Help?

Browse our Documentation or contact Support to get your questions answered. To report a bug, please post to our GitHub Issue Tracker.

See our Terms & Conditions for licensing and refund details.

Pono Press

  • Terms & Conditions
  • Guides
  • Support

Copyright@2020 Pono Press

Powered by crazy ideas and passion.