As part of my theme install, I'd like to add a set of custom field options to the wordpress database that would be available to all posts as long as my theme is active.
For example, I'd like to add these fields:开发者_开发问答
custom-image-1 custom-image-2 custom-image-3
And also these
custom-image-1-link custom-image-2-link custom-image-3-link
And then when a user goes to add or edit a post, they can insert values for each of these fields if they choose to...
You simply have to create a post and add these custom fields once to have them proposed for every next posts (in the custom fields part of the form).
If you need to create a more integrated interface for these extra fields, you might be better off creating a plugin or looking for existing ones, such as this one.
Use the add_meta_box
function that comes with WordPress.
https://developer.wordpress.org/reference/functions/add_meta_box/
精彩评论