I currently have some custom post types "shops" (actually more like pages than posts) and a custom taxonomy "products" linked to those post types.
I'm attempting to create a form (via shortcode) that allows the user to select one (or potentially more in the future) products that when submitted, shows a page listing shops (title and other post meta) related to the chosen product(s).
I have the form, just not sure what the best way is to handle the submission and subsequent display page.
I noticed the codex page for add_rewrite_endpoint() states
This can be used for all sorts of things:
- ajax handler
- form submission handler
- alternative notification handler
however there's no further information about how to achieve this.
Any pointers on handling form submissions would be great. Thanks.
Edit: Further on this, I want the form submission page to redirect to a nice URL representing the selected term. For example
- User selects product "books", hits submit
- Form submits to handling URL or some kind of hook catches the submission
- The browser is redirected to "shops/books"
- Something displays the "shop" pages tagged with "books" products
My question can be broken down to...
- What URL do I use in the form's
action
attribute? Is this even necessary? - Where do I handle the form submission? Do I create a specific file or can I register some kind of action hook. Keep in mind that I'm wanting to send a
Location
header to redirect to another URL so this needs to happen prior to any output sent to the browser. - How do I configure something to accept the "shops/%product%" request and show results accordingly
Sorry for the long-winded query but I'm struggling to get to grips with the Wordpress API and documentation.