Exclude pages specific

Posted in: Newspaper
Post count: 14

Hi guys,

I put this passage in my functions to exclude pages (ID 1, 2, 3 and 4) WP search.
function SearchFilterPageSpecific( $query ) {
if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
$query->set( 'post__not_in', array( 1,2,3,4 ) );
}
}
add_action( 'pre_get_posts', 'SearchFilterPageSpecific' );

Accessing the direct url: example.com/?s=search is exclude correctly.

More by ajax search theme, the pages you want to delete this search appears normally.

Any suggestions to solve this?

Grateful.

Version:
WordPress = 4.6
Newspaper = 7.3

—–
TRADUZIDO DE:
Coloquei esse trecho no meu functions para excluir as páginas (ID 1, 2, 3 e 4) da busca WP.
CÓDIGO
Acessando pela url direta: example.com/?s=search está ocultando corretamente.
Mais pela busca ajax do tema, as páginas que gostaria de excluir dessa busca aparecem normalmente.
Alguma sugestão para resolver isso?
Grato.

Post count: 22421

Hello,
The ajax search from our theme is custom made so any code related to the standard wp search will not work in this case. You can find the ajax search here: http://screencast.com/t/5I3vmQI51JP You will need to edit the js function to do it. unfortunately there is no easy solution I can provide for this. If you do not know the steps you need to take in this regard, we recommend hiring a developer to help out with the code.
Thank you!

Post count: 22

Hey Gllvancn,

if you are still looking its a pretty simple change. Look in:
/themes/Newspaper/includes/wp_booster/td_data_source.php
at line 376

just modify this function:

/**
* used by the ajax search feature
* @param $search_string
* @return WP_Query
*/
static function &get_wp_query_search($search_string) {
$args = array(
's' => $search_string,
'post_type' => array('post', 'page'),
'posts_per_page' => 4,
'post_status' => 'publish'
);

$td_query = new WP_Query($args);
return $td_query;
}

I could not figure out how to overide it in my functions, so I will have to change it after every update, but I needed a way to remove all the “hidden” products in woo-commerce.

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.