Search box - header-contact

I am trying to add a search box to our site https://fspaustralia.com.au
from the forums, I tried (below) but it hasn’t worked my goal is to have the search box in the .header-contact at top of the page currently it appears in the footer

Java script

    ;(function($) {

       'use strict'
       
       $('.mainnav form#searchform').remove().clone().appendTo('.header-contact .container');
       
    })(jQuery);

Addition css

    .header-contact .container {
      position: relative;
    }

    .header-contact #searchform {
      position: absolute;
      top: 0;
      right: 0;
    }

Hello there,

It seems like one step as mentioned in this thread was missed.

Use Code Snippets plugin to apply the below function to your site.

    add_filter('wp_nav_menu_items', 'woo_custom_product_searchform', 10, 2);
    function woo_custom_product_searchform($items, $args) {

      if( $args->theme_location == 'primary' ) {

        $items .= '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/'  ) ) . '">
              			<label class="screen-reader-text" for="s">' . __( 'Pesquisar por:', 'woocommerce' ) . '</label>
              			<input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . __( 'Pesquisar produtos...', 'woocommerce' ) . '" />
                    <input type="hidden" name="post_type" value="product" />
              		</form>';

      }

      return $items;

    }

Regards,
Kharis

I have added the code still no luck

Hello there,

Custom JavaScript isn’t for PHP code. Please use Code Snippets plugin instead.

Regards,
Kharis

Hi Kharis thanks for your help
Still no luck
Have I implemented the snippet and css correctly?

image

Hello there,

Has the snippet already activated? Flush site caching as it usually blocks recent code addition to take immediate effect in the front end. https://codex.wordpress.org/I_Make_Changes_and_Nothing_Happens

Regards,
Kharis

thank you it was not active.

ANy way to change the default text in the search box?

All good I worked it out thanks for your Help

Great! You’re welcome!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis