Documentation

View the installation guide, browse the Knowledge Base, read the FAQ, find out about SearchWP's many hooks, get support

Configuration

If you’re simply looking to instantly enhance the relevance of searches on your WordPress powered website, you can rest assured that SearchWP will do that for you without any extra configuration steps. On the other hand, if you’d like to fine-tune the weights SearchWP uses to rank it’s results, you can do that in just a few minutes. SearchWP was built in response to WordPress conventions. It knows that keywords are likely to show up in any number of places, each of which may have varying importance post type to post type. That’s why you’re able to define keyword weights for everything individually in SearchWP.

Customize included post types

When activated, SearchWP will establish a default set of settings that mimics what a native WordPress search would have performed. It checks all registered post types to see which are not set to be excluded from search. It enables those post types and sets up a default set of weights for each content location (where applicable):

  • Title
  • Content
  • Slug
  • Individual Taxonomies
  • Excerpt
  • Comments
  • Individual Custom Fields

If a post type does not support one of the above, it will be omitted from the settings page and search algorithm entirely. You also have the option to exclude post IDs, enter comma separated IDs you’d like to exclude from search results.

Note: Custom Field support was integrated in such a way to best work with existing WordPress installations. For example, SearchWP doesn’t care what type of data is stored in your Custom Field in the database itself. If you’ve stored serialized or JSON encoded data, SearchWP will decode it before indexing the content, so even array values and object properties will be indexed.

Attributing search results

This is a bit of a unique feature to SearchWP, but once explained it might prove to be immensely useful. There are certain circumstances where you might use a custom post type to house any number of entries, but depending on the site design they might not have (or need) permalinks. In this case the CPT content would be pulled into a parent Page, which in fact deserves the ‘credit’ for search results that point to the CPT entry. With SearchWP you can attribute that keyword weight to the Page displaying your content, and credit will be given to the Page itself as opposed to the single CPT entry.

Keyword stemming

Retrieving relevant results is important, but language is a very complex thing. Keyword stemming is a technique that broadens search queries to include various forms of each term. For example, with stemming enabled searches for “fishing”, “fished”, “fisher”, and “fish” would all yield the same result set, whereas with stemming disabled the algorithm would look only for the exact terms in the query. Some people prefer more strict results while others feel keyword stemming provides more relevance, it comes down to the content on your site and what people are searching for.


Supplemental Search Engines

SearchWP allows you to create additional search engines, utilizing the main index to find segmented results based on the same set of options you use for the site-wide, default search engine. This allows you to create additional search engines to utilize within sections of your website (e.g. with a single Custom Post Type only) without interfering with the main site search. No reindexing is required, simply create and configure any number of supplemental search engines and interact with them like so:

<?php
/* Template Name: SearchWP Supplemental Search Results */
global $post;
// retrieve our search query if applicable
$query = isset( $_REQUEST['swpquery'] ) ? sanitize_text_field( $_REQUEST['swpquery'] ) : '';
// retrieve our pagination if applicable
$swppg = isset( $_REQUEST['swppg'] ) ? absint( $_REQUEST['swppg'] ) : 1;
if ( class_exists( 'SWP_Query' ) ) {
$engine = 'bbpress'; // taken from the SearchWP settings screen
$swp_query = new SWP_Query(
// see all args at https://searchwp.com/docs/swp_query/
array(
's' => $query,
'engine' => $engine,
'page' => $swppg,
)
);
// set up pagination
$pagination = paginate_links( array(
'format' => '?swppg=%#%',
'current' => $swppg,
'total' => $swp_query->max_num_pages,
) );
}
get_header(); ?>
<section id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<header class="page-header">
<h1 class="page-title">
<?php if ( ! empty( $query ) ) : ?>
<?php printf( __( 'Search Results for: %s', 'twentyfifteen' ), $query ); ?>
<?php else : ?>
SearchWP Supplemental Search
<?php endif; ?>
</h1>
<!-- begin search form -->
<div class="search-box">
<form role="search" method="get" class="search-form" action="<?php echo esc_html( get_permalink() ); ?>">
<label>
<span class="screen-reader-text">Search for:</span>
<input type="search" class="search-field" placeholder="Search …" value="" name="swpquery" title="Search for:">
</label>
</form>
</div>
<!-- end search form -->
</header><!-- .page-header -->
<?php if ( ! empty( $query ) && isset( $swp_query ) && ! empty( $swp_query->posts ) ) {
foreach ( $swp_query->posts as $post ) {
setup_postdata( $post );
// output the result
?>
<div class="search-result">
<h2>
<a href="<?php echo get_permalink(); ?>">
<?php the_title(); ?>
</a>
<?php the_excerpt(); ?>
</h2>
</div>
<?php
}
wp_reset_postdata();
// pagination
if ( $swp_query->max_num_pages > 1 ) { ?>
<div class="navigation pagination" role="navigation">
<h2 class="screen-reader-text">Posts navigation</h2>
<div class="nav-links">
<?php echo wp_kses_post( $pagination ); ?>
</div>
</div>
<?php }
} else {
?><p>No results found.</p><?php
} ?>
</main><!-- .site-main -->
</section><!-- .content-area -->
<?php get_footer();
view raw gistfile1.php hosted with ❤ by GitHub

For a more detailed walkthrough, please see this KB article: Setting up a Supplemental Search Engine: Step by Step


Reset (Purge) the Index

If at any time you would like to completely purge (delete all contents) of SearchWP’s index, you can do so by viewing the Advanced settings tab and clicking the button:

Once the index has been reset you will be presented with a link to rebuild the index.

Fix Search on Your Site. No Coding Required!

Now you can utilize all of the content that's gone unrecognized by native WordPress search instantly with SearchWP

Get SearchWP