I´m trying to find a snippet to add a predefined custom field. Does anyone know how or where i can find this?
I know I can do this with CustomPress, but I´m trying to do this without a plugin.
I´m trying to find a snippet to add a predefined custom field. Does anyone know how or where i can find this?
I know I can do this with CustomPress, but I´m trying to do this without a plugin.
You must be logged in to post a comment.
Take a look at adding a custom meta box for any type of predefined meta field.
add_meta_box – Docs – WordPress
You will need to add a hook to the ‘save_post’ action in order to save the meta data also.
Here is a quick and simple version:
That should get you started; comment back if something is amiss.
Just add the above code anywhere in your themes function.php.
After you’ve added the above code, it would add ‘www.cyberxoft.com’ to the drop down as one of the option to select.
If you get to see it, then just replace ‘www.cyberxoft.com’ with your required field name and refresh the admin page and when you see that happened just go ahead and add as many as you like BUT remember that only 30 could be viewed as thats the default limit set for it.
Enjoy…
You could also find this solution at Programatically add options to “add new” custom field dropdown