Okay
  Public Ticket #280652
Custom search function?
Closed

Comments

  • Callum started the conversation

    Hi, 

    I've been trying to override the default search function as I want to add my own form action.  I've tried a few things like creating a searchform.php template or inserting a custom function into functions.php but I still can't get it to work.  I am using salient as a child theme.

    function my_search_form( $form ) {

    $form = '<form action="http://myurl.com/search" role="search" method="get" id="searchform">

    <input type="text" size="15" name="I_DSC">

    <input type="submit" value="Search Archive">

    <input type="hidden" name="I_DSC_AND" value="t">

    <input type="hidden" name="_ACT" value="search">

    </form>';

    return $form;

    }

    add_filter( 'get_search_form', 'my_search_form' );

    Can you help?

  •  1,070
    ThemeNectar replied

    Hey Callum,

    the actual searchform file is located at includes/header-search.php - the best way to override that would be to use a custom header.php in your child theme so you can alter this line to the location of your custom file:

    get_template_part('includes/header-search');

    Cheers

  • Callum replied

    Hi, 

    The reason I haven't used a custom header.php file is that method is not good for theme updates.  Any changes you guys make to header.php in the future would not be pulled through to my header.php without manual intervention.

    I'm trying to use the filter "get_search_form" but noticed you're calling "get_template_part" in the header.  If I was to modify the custom function I wrote in my first message can you give any help on how I would modify this to work with the theme?

    Thanks 

  •  1,070
    ThemeNectar replied

    I believe you could just also create a directory called includes in your child theme and add a file called "header-search.php" into it and that should be used in the child theme