I’d like users to be able to create and remove additional meta box fields as needed.
For example, say a music podcast with a variable amount of songs played per episode.
The user should be able to click a button that will add additional fields to enter each song as needed.
Ideally this would be done without the use of a plugin, but coded into the functions file.
So you mean something like this?
and when you click on Add tracks it becomes this:
If this is what you mean, it’s done by creating a metabox that has a simple jQuery function to add and remove fields in it, and the data is saved as an array in of data in a single meta row, here you go:
This is done through custom fields BUT you should never use anything that lets users
addcreate or remove meta boxes. These write directly into the database so you could potentially create a whole lot of problems for your site if you give users this kind of control. It’s far safer for you to create the maximum number of custom fields they may need and let them leave some blank where they are not needed.This is also plugin territory. The functions file is theme-specific whereas plugins are for functions that apply to the site content, especially if you want that content to be available regardless of which theme you use.
Some suggestions:
http://wordpress.org/extend/plugins/verve-meta-boxes/
http://wordpress.org/extend/plugins/more-fields/