• Hi there! I am creating a custom theme for my blog to make posting pretty straightforward. Thus, I’ve created 5 custom post types, with custom meta boxes and fields for each one.

    For a particular custom post type, ‘concerts’, I have created a custom meta box that will contain all the information about the event. For the ‘venue’ field, I would like to create a dropdown that lets you choose between:

    – ‘Add new’. In that case, some text fields would show up to enter the venue name, address, website….
    -Venues that have already been registered

    This means that the information fields about each venue should be stored in a database, so that I don’t have to write them down every time I add a concert. Or at least that is my guess…

    I have been searching online for a few days but I can’t seem to find anything useful, plus I am not very familiar with mysql

    Any clue where I should search, any tutorial? Every help is appreciated!

    For some extra points, I would also like to add a date and time picker, I’ve looked up here, but don’t know how to implement it.

    Thanks in advance

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    You could just create your own table to store venues, in which case you’ll need to get more familiar with mysql. What you have in mind wouldn’t require more than the fundamentals.

    The best approach may be to create a venue taxonomy and add terms for each venue. Then you can use the built in taxonomy tools and maybe avoid the nitty gritty of mysql.

    For the picker, your goal would be to alter your templates so the html of the page on your blog where the picker appears looks more or less like the html of the page you linked, in particular the script tags and links to external files, as well as the actual form. WP already uses jQuery, so be sure to reference the new script files using wp-enqueue_script(). There’s a similar function to enqueue style files. You should also copy all these external files from the author’s site to your server.

    Thread Starter muydelpalo

    (@muydelpalo)

    Thanks a lot! I think I am going to try and learn some mysql first, it may come handy in the future.

    About the field that goes from a dropdown with all the venues to text fields if you want to add a new venue, how can that be done? I’ve been trying to google it but I always get results about dropdown menus on the frontend

    Thanks again!

    Moderator bcworkz

    (@bcworkz)

    mySQL skills will definitely be useful. I need to learn more as well.

    There’s a few approaches to adding data fields. Easiest would just have a link near the form element one could click to add venues. Which loads a form, which submits the new data, which adds the data.

    Or you could have an Add New Venue… element in the drop down, whose selection is trapped by javascript, triggering a form load, etc.

    Thread Starter muydelpalo

    (@muydelpalo)

    So javascript as well… Do you know what that function is called? Or how to google it?

    Moderator bcworkz

    (@bcworkz)

    The form element EVENT is called “onchange”. It is assigned any javascript function you want. You might start your research here: http://www.w3schools.com/tags/ev_onchange.asp .

    This will fire on any change, your function will need to check what was selected to decide if it should request the form or not.

    So javascript as well…

    Never seems to end, eh? May as well look at jQuery while you’re at it 🙂

    Thread Starter muydelpalo

    (@muydelpalo)

    Well thanks a lot! This will keep me occupied some time, but i’ll keep you posted on the progress

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘custom field database’ is closed to new replies.