I have a form I've developed that creates a WP_Query to search through a custom post type in Wordpress.

There are 4 fields: title, author, orderby(selectbox), order(selectbox)

Say the user types in "cats" in title and presses search, my URL will look like this:


I'd prefer to have the URL simply be


Since the rest are the "default" values and/or blank. I'm not hooking this into JavaScript anywhere, but is that my only solution? I feel like WordPress would have a helper function for this somewhere.

The HTML for the form is a simple:

<form role="search" method="get" class="cpt-search-form" action="">
  • I’m afraid that html forms don’t work like that - all fields are sent and it’s normal behavior... Feb 29, 2020 at 17:31
  • @KrzysiekDróżdż Might be "normal" but there is a way around it. I imagine a way to hook the form into a function. Parse it. And manually append query args if they're not "default values" Feb 29, 2020 at 18:48
  • Forms doesn’t work that way. Form sends all its fields. You can’t “filter them” - filters are working on your server, and form works in browser and generates requests... So seriously - don’t mess with it - just process the request properly, as all internet is doing... I’m also sorry, but I’m afraid this question has not much to do with WP, so it’s off-topic in here, I guess... Feb 29, 2020 at 18:53


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.