WordPress

How to Customize the Default Search Form in WordPress

A client whose site we recently rebuilt on WordPress came up with an unusual request: they asked two search forms on each page–one searching the site, the other a catalog on another site.

Fortunately, the Avada theme we used allows you to have a search form in both the header and the footer, so taking care of that part of the request was easy.  It looked to me like the tricky part would be in getting the forms to submit to different locations.

Warning: creating a form that submits data to another site without the site-owner’s knowledge and permission amounts to a cross-site scripting attack.  You’re using your form to inject data into the other site’s code.

Luckily, in the case of the catalog site, the vendor allows customers to create their own off-site search forms and even advises them on how to do it.  Obviously, they’ve taken extra measures to sanitize the posted data, and obviously your form needs extra measures to sanitize the data before it’s posted.  (For this article, I cover only the basics of jQuery, not the extra measures.)  Unless you know you have the blessing of the other site, then you’re attacking the other site, whatever your intentions.

That being said, here’s how you can customize the default WordPress search form action with jQuery.  Download How_to_Customize_the_Default_Search_Form_in_WordPress.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *