Term Archive Priority

Current version: 1.2.1 View Changelog

Download available with active license

The Term Archive Priority Extension will force taxonomy term archive pages to bubble to the top of search results when a match is found. This allows you to search by taxonomy term and have applicable taxonomy archive pages show up within your search results!

This Extension only applies to supplemental search engines.

Out of the box, all supplemental search engines will apply this change when the plugin is active, but you can filter that down to specific supplemental search engines by doing something like the following:

function my_maybe_include_term_archive( $include, $engine, $terms ) {
// only have term archives included for supplemental search engine with name 'supplemental'
return ( $engine == 'supplemental' ) ? true : false;
add_filter( 'searchwp_term_archive_enabled', 'my_maybe_include_term_archive', 10, 3 );
view raw gistfile1.php hosted with ❤ by GitHub

NOTE: by default, Term Archive Priority supports exact taxonomy term matches. If you would like to enable matching of any word within a taxonomy term, use the following filter:

add_filter( 'searchwp_tax_term_or_logic', '__return_true' );
view raw gistfile1.php hosted with ❤ by GitHub

Once activated, you will need to customize your search results loop so as to account for term archive pages in the results. This is a full theme template example outlining how to properly implement the Term Archive Priority Extension:

/* Template Name: SearchWP Custom Search */
global $post;
$query = isset( $_GET['searchwpquery'] ) ? sanitize_text_field( $_GET['searchwpquery'] ) : '';
$page = isset( $_GET['swppage'] ) ? absint( $_GET['swppage'] ) : 1;
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php if( !empty( $query ) ) : ?>
<header class="page-header">
<h1 class="page-title">Search Results for: <?php echo $query; ?></h1>
<?php endif; ?>
<div class="entry-content">
<form action="" method="get">
<legend>Supplemental Search</legend>
<label for="searchwpquery">Search</label>
<input type="text" id="searchwpquery" name="searchwpquery" value="<?php echo esc_attr( $query ); ?>" />
<p><button type="submit">Search</button></p>
<?php if( !empty( $query ) ) : ?>
$engine = SearchWP::instance(); // instatiate SearchWP
$supplementalEngineName = 'supplemental'; // search engine name
// perform the search
$posts = $engine->search( $supplementalEngineName, $query, $page );
<?php if( !empty( $posts ) ) : ?>
<?php foreach( $posts as $post ) : ?>
<?php if( $post instanceof SearchWPTermResult ) : ?>
<header class="entry-header">
<h1 class="entry-title">
<a href="<?php echo $post->link; ?>" rel="bookmark"><?php echo $post->taxonomy; ?>: <?php echo $post->name; ?></a>
</header><!-- .entry-header -->
<div class="entry-summary">
<p><?php echo $post->description; ?></p>
</div><!-- .entry-summary -->
<?php else : setup_postdata( $post ); ?>
<header class="entry-header">
<h1 class="entry-title">
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
</header><!-- .entry-header -->
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
</div><!-- #content -->
</div><!-- #primary -->
view raw gistfile1.php hosted with ❤ by GitHub



  • [Fix] PHP Warning
  • [Update] Updates updater


  • [New] Support for SearchWP 4


  • [New] Support for Live Search
  • [Update] Updated updater


  • [Fix] Number of arguments passed to searchwp_term_archive_term_args
  • [Fix] Fatal Error when SearchWP is not active
  • [Fix] Check for SearchWP core partial matching setting


  • [Fix] Fixes an issue with shared taxonomies not appearing in results


  • [Fix] Fixes an issue with Live Search integration being too assumptive, it is now opt-in
  • [New] New filter searchwp_term_archive_live_search to opt in to Live Search integration


  • [New] New filter searchwp_term_archive_term_args
  • [Improvement] Better support for Live Ajax Search searches
  • [Update] Updated updater


  • [Change] Empty terms are no longer ignored by default when using OR/%LIKE% matching
  • [New] New filter searchwp_term_archive_term_args to customize OR/%LIKE% arguments


  • [Fix] Fixed an issue with improper results containing terms spanning multiple post types
  • [Update] Updated updater


  • [Improvement] Better integration with LIKE Terms/Fuzzy Matches for martial term matching


  • [Improvement] Automatic updates based on your SearchWP license key


  • [Improvement] Formatting


  • [Fix] Better offset handling
  • [Fix] PHP Warning cleanup
  • [Improvement] Results now ordered by the weight of their taxonomy


  • [New] New filter searchwp_tax_term_or_logic that allows OR logic in multi-word terms


  • [Fix] Fixed an issue where disabled post types were not taken into account


  • [Fix] Fixed an issue where taxonomies were being set before custom taxonomies were registered
  • [Improvement] Consider multi-word terms


  • Initial release
Fix keyword search on your site. No coding required!

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

Get SearchWP