Change Search Link


We are uploading a new product filter. We are serving static HTML/JS/CSS files from a /products subfolder that is uploaded to the root directory.
This means WordPress is acting as a static HTTP server.

I need to change the link that the search box uses in the header of our website.
The new link needs to be: /products/search/1

I noticed the header.php and searchform.php both have the same string (there is a search.php file, but I don’t see the below string):

<?php echo home_url('/'); ?>

Should I replace the “/” with “/products/search/1” so the string now looks like?

<?php echo home_url('/products/search/1'); ?>

Below is code form the header.php and searchform.php files if this helps.


<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
                            <span class="screen-reader-text"><img src="<?php echo get_template_directory_uri(); ?>/images/search.png" alt="S" /></span>
                            <input type="search" class="search-field" placeholder="Search …" value="" name="s" title="Search for:" />
                        <input type="submit" class="search-submit" value="Search" />


<form role="search" method="get" id="searchform" action="<?php echo home_url('/'); ?>">
    <div class="row collapse">
        <?php do_action('themename_searchform_top'); ?>
        <div class="small-8 columns">
            <input type="text" value="" name="s" id="s" placeholder="<?php esc_attr_e('Search', 'themename'); ?>">
        <?php do_action('themename_searchform_before_search_button'); ?>
        <div class="small-4 columns">
            <input type="submit" id="searchsubmit" value="<?php esc_attr_e('Search', 'themename'); ?>" class="prefix button">
        <?php do_action('themename_searchform_after_search_button'); ?>

This is in the functions.php file, but not sure what it’s purpose is:

add_theme_support('html5', array('search-form'));

function get_term_top_most_parent($term_id, $taxonomy){
    // start from the current term
    $parent  = get_term_by( 'id', $term_id, $taxonomy);
    // climb up the hierarchy until we reach a term with parent = '0'
    while ($parent->parent != '0'){
        $term_id = $parent->parent;

        $parent  = get_term_by( 'id', $term_id, $taxonomy);
    return $parent;

I found these articles, but not 100% sure this is the solution I need since this issue is new to me:
WordPress custom search url
Change the search URL

, Webman 3 years 2019-12-04T11:53:00-05:00 0 Answers 108 views 0

Leave an answer