This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

title in search input

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #12424
    Laurent Le NyLaurent Le Ny
    Participant

    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.

    [code]// 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;
    }}[/code]

    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

    #12434
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘title in search input’ is closed to new replies.