Append data to the native search: ------------------------------------- You can try for example: add_action( 'pre_get_posts', function( $q ) { if( $q->is_main_query() && $q->is_search() ) { $q->set( 'nopaging', true ); add_filter( 'posts_request', function( $request ) { $sql = 'YOUR EXTRA SQL QUERY'; return "({$request}) UNION ({$sql}) ORDER BY post_status DESC"; }); } }); where we use the *no paging* version to match your SQL query. Reuse the search query: ------- Well, if I understand your comment correctly you want to reuse the main search query in your extra SQL query. Here's one idea: /** * Append data to the native search * * @see http://wordpress.stackexchange.com/a/161949/26350 */ add_action( 'pre_get_posts', function( $q ) { if( $q->is_main_query() && $q->is_search() ) { $q->set( 'nopaging', true ); $c = new WPSE_Search; $c->init(); } }); where the `WPSE_Search` class is: /** * class WPSE_Search */ class WPSE_Search { protected $search_where = ''; public function init() { add_filter( 'posts_search', array( $this, 'posts_search' ) ); add_filter( 'posts_fields', array( $this, 'posts_fields' ) ); add_filter( 'posts_request', array( $this, 'posts_request' ) ); add_filter( 'posts_orderby', '__return_null' ); } public function posts_search( $search ) { $this->search_where = $search; return $search; } public function posts_fields( $fields ) { return 'ID, post_title, post_content, post_status'; } public function posts_request( $request ) { global $wpdb; $search_where = str_ireplace( array( $wpdb->posts . ".post_", "AND (password = '')" ), "", $this->search_where ); $sql = "SELECT ID, title as post_title, content as post_content, status as post_status FROM {$wpdb->prefix}software_and_hardware_post WHERE 1=1 {$search_where} AND status=1"; return "({$request}) UNION ({$sql}) ORDER BY post_status DESC"; } } // end class