How to get Sitelinks search box for your website

Sitelinks search box can be obtained by adding the following JSON LD code to your website.

<script type="application/ld+json">{   
  "@context": "http://schema.org",   
  "@type": "WebSite",   
  "url": "https://www.yourwebsite.com/",   
  "potentialAction": {     
    "@type": "SearchAction",     
    "target": "http://www.youwebsite.com/search.html?q={search_term_string}",
    "query-input": "required name=search_term_string"   
  } 
}</script>

In the above script replace https://www.yourwebsite.com with your website URL. Replace “q” with your website’s search query parameter. For wordpress sites, replace “q” with “s”.