How Aurora’s Search Works
Aurora restricts its search to the post post type using a pre_get_posts hook. This is a deliberate design choice that keeps results focused on blog posts and avoids surfacing pages, attachments, or other post types. Understanding what this means helps you decide whether the default behaviour fits your site or needs extending.
What Gets Searched by Default
Aurora restricts search to the post post type only. Within that, WordPress core handles the matching. By default it searches against:
- Post title — the full title is searched
- Post content — the full body content is searched
Pages, custom post types, custom fields, tags, and categories are excluded. Aurora does not control which fields WordPress matches against. That is WordPress core behaviour. To extend either the post types searched or the fields matched, add your own hooks in your child theme.
Where Results Appear
Search results render using Aurora’s search results layout, configured from Appearance → Customize → Layouts → Search Results Layout. Aurora ships with three designs: Default, Bold, and Cover. See How to Configure the Search Page for settings, and Aurora Search Results Layouts: All 3 Designs Compared for a visual comparison. You can also preview them on the demo site.
Extending Search Behaviour
The following snippets go in your child theme’s functions.php. See Using a Child Theme with Aurora for how to set one up.
Include Pages in Search Results
Aurora’s hook sets search to posts only. To include pages alongside posts, override it in your child theme:
add_action( 'pre_get_posts', function( $query ) {
if ( $query->is_search() && $query->is_main_query() && ! is_admin() ) {
$query->set( 'post_type', [ 'post', 'page' ] );
}
} );
Include a Custom Post Type
Replace 'your_post_type' with your CPT slug:
add_action( 'pre_get_posts', function( $query ) {
if ( $query->is_search() && $query->is_main_query() && ! is_admin() ) {
$query->set( 'post_type', [ 'post', 'your_post_type' ] );
}
} );
Search by Custom Field (Meta)
WordPress does not search custom field values by default. To include a specific meta field in the search, filter the SQL query directly:
add_filter( 'posts_search', function( $search, $query ) {
if ( ! $query->is_search() || ! $query->is_main_query() || is_admin() ) {
return $search;
}
global $wpdb;
$term = $query->get( 's' );
if ( ! $term ) return $search;
$like = '%' . $wpdb->esc_like( $term ) . '%';
$search .= $wpdb->prepare(
" OR EXISTS (
SELECT 1 FROM {$wpdb->postmeta}
WHERE {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID
AND {$wpdb->postmeta}.meta_key = 'your_meta_key'
AND {$wpdb->postmeta}.meta_value LIKE %s
)",
$like
);
return $search;
}, 10, 2 );
Replace 'your_meta_key' with the actual meta key you want to include.
These snippets use the pre_get_posts and posts_search hooks, standard WordPress filters that work independently of Aurora. They will not conflict with any theme functionality. For more code customisations, see the CSS Variables and other entries in the Code & Snippets category.
Search and the Sidebar
The sidebar shown on search results pages follows the same setting as archive pages. Toggle it from Appearance → Customize → Layouts → Archive Layout → Sidebar. See How to Show or Hide the Sidebar.
