I am trying to create a more transferrable/automated custom post type that would act as a error ticketing system (I know there are many out there, but I want one that is completely customised).
The CPT I have is called ticket
with two taxonomies ticket_stage
and ticket_application
.
I also have the meta fields:
closed
- checkboxpriority
- selectcomputer
- selectstatus
- selectsubmitter_name
- input field (automated via logged in user)submitter_email
- input field (automated via logged in user)
From the backend, it is easy to create a ticket, and assign all the right fields.
From the frontend, I am only able to pass the title
, date
, ticket_stage,
ticket_application,
post_bodyvia the
wp_insert_post()`
I am able to manually create the meta fields and pass them, but I wanted to know if it was possible to loop the possible values in case there are future additions (say computer
fields are removed or added). I tried searching for ways to loop meta fields, but without a post id, or anything written to the database for a post it is not know.
The only way I have been able to do it, but not sure if it is safe or not is this way:
During the creation of the meta fields, following this tutorial http://code.tutsplus.com/articles/reusable-custom-meta-boxes-part-1-intro-and-basic-fields--wp-23259 when you get to switching the fields switch($field['type'])
, I duplicate the entire function, give it a new name, an rearrange the fields. Then on the frontend page, I call the new function and pass them through a form.
Is that way safe, or recommended? Is there a better way to call metabox fields without manually writing out each key and updating when new keys are added?
I tried looking into using only taxonomies, and replacing certain taxes with radio buttons or select dropdowns, only to see codes that replaced all the taxes instead of individual ones.
The main reason to make them taxes, was so I could get the menu item for them, which I again couldn't find in any documentation.