soderlind/wp-loupe

Search engine for WordPress. It uses the Loupe search engine to create a search index for your posts and pages and to search the index.

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 50

Watchers: 2

Forks: 0

Open Issues: 2

Type:wordpress-plugin

0.0.31 2025-02-27 22:39 UTC

README

A powerful search enhancement plugin for WordPress that delivers fast, accurate, and typo-tolerant search results.

Quick Links

Features | Installation | Usage | FAQ | Filters | Changelog | TODO

Overview

WP Loupe transforms WordPress's search functionality by:

  • Creating a dedicated search index for lightning-fast results
  • Supporting typo-tolerant searches
  • Offering phrase matching and advanced search operators
  • Automatically maintaining the search index
  • Providing customization options for developers

Features

Core Features

  • πŸš€ Enhanced search engine replacing WordPress default
  • ⚑ Lightning-fast, precise result delivery
  • πŸ”„ Real-time index synchronization
  • 🌐 Support for multiple languages
  • πŸ“¦ Full custom post type integration
  • πŸ“ˆ Integrated search performance metrics
  • βœ… Seamless compatibility with WordPress default themes

Search Capabilities

  • πŸ” Typo-tolerant searching
  • "..." Phrase matching with quotation marks
  • - Exclusion operator support
  • πŸ“– Pagination support

Developer Features

  • πŸ› οΈ Extensive filter system
  • πŸ“Š Performance monitoring
  • πŸ”§ Customizable indexing

Installation

  1. Quick Install

    • Download wp-loupe.zip
    • Upload via WordPress Plugins > Add New > Upload Plugin
  2. Composer Install

    composer require soderlind/wp-loupe
  3. Post-Installation

    • Activate the plugin
    • Go to Settings > WP Loupe
    • Click "Reindex" to build the initial search index

Usage

Basic Search

  • Type normally in your search box
  • Results are instant and typo-tolerant
  • Matches are highlighted in results

Advanced Search Operators

  • Hello World will search for posts containing Hello or World.
  • "Hello World" will search for posts containing the phrase Hello World.
  • Hello -World will search for posts containing Hello but not World.

FAQ

How does it handle updates to posts?

The search index automatically updates when content is created, modified, or deleted.

Will it slow down my site?

No. WP Loupe uses a separate, optimized search index and doesn't impact your main database performance.

Can I customize what content is searchable?

Yes, using filters you can control exactly what content gets indexed and how it's searched.

Does it work with custom post types?

Yes, you can select which post types to include in the Settings page or via filters.

Filters

  1. wp_loupe_db_path: This filter allows you to change the path where the Loupe database files are stored. By default, it's in the WP_CONTENT_DIR .'/wp-loupe-db' directory.
add_filter( 'wp_loupe_db_path', WP_CONTENT_DIR . '/my-path' );
  1. wp_loupe_post_types: This filter allows you to modify the array of post types that the WP Loupe plugin works with. By default, it includes 'post' and 'page'.
add_filter( 'wp_loupe_post_types', [ 'post', 'page', 'book' ] );
  1. wp_loupe_filterable_attribute_{$post_type}: This dynamic filter allows you to modify the array of filterable attributes for each post type. By default, it includes 'post_title' and 'post_content'.
add_filter( "wp_loupe_filterable_attribute_book", [ 'post_title', 'author', 'isbn' ] );
  1. wp_loupe_posts_per_page: This filter allows you to modify the number of search results per page. By default it's 10, set in WPAdmin->Settings->Reading->"Blog pages show at most".
add_filter( 'wp_loupe_posts_per_page', 20 );
  1. wp_loupe_index_protected: This filter allows you to index posts and pages that are protected by a password. By default, it's set to false.
add_filter( 'wp_loupe_index_protected','__return_true' );
  1. wp_loupe_schema_content: This filter allows you to modify the content before it's indexed. By default, removes HTML comments from content (i.e. remove WordPress block comments).
add_filter('wp_loupe_schema_content', function($content) {
	// Modify content before indexing
	$content = preg_replace('/<!--(.*?)-->/s', '', $content);
	return $content;
});

Acknowledgements

WP Loupe is built upon Loupe. Loupe is licensed under the MIT license.

Copyright and License

WP Loupe is copyright Β© 2024 Per SΓΈderlind.

WP Loupe is open-source software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation.

WP Loupe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE for more information.