开发者

Wordpress: add a custom field option that's available to all posts

开发者 https://www.devze.com 2022-12-19 20:04 出处:网络
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.

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号