admin管理员组

文章数量:1390399

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:

?spot_title=cats&spot_author=&spot_orderby=date&spot_order=desc

I'd prefer to have the URL simply be

?spot_title=cat

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="">

本文标签: wp queryWordpress custom search formignore emptydefault input fields upon submission