Hello I would like to evolve a function that I put in place which consists of taking the title of the page in progress in the search bar.
I put this code in the functions.php file and I do not want to apply it to certain templates or pages.
// prefilled input search ajax search pro
add_filter( 'asp_print_search_query', 'asp_change_search_text', 1, 1);
function asp_change_search_text( $text ) {
if (is_page_template('template-home.php') || ('404.php')) { // or whatever other condition you like
remove_filter( 'asp_print_search_query', 'asp_change_search_text' );
return $text;
} else {
$s = get_the_title();
if ( !is_wp_error($s) && !empty($s) )
return $s;
return $text;
}}
it’s work only for the first template but not for error 404 template
I don’t understand why.
Can you help me please ?
Thank you very much your plugin is amazing