title in search input

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 7 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #12424
    Laurent Le Ny
    Laurent 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.

    // 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

    #12434
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘title in search input’ is closed to new replies.