Adding set of custom fields to WordPress Post in Dashboard

I am working on a WordPress site and while creating a new posts we have certain number of custom attributes which are always part of the post, as of now we need to manually add those all custom fields while creating the post.

I am looking a way so that when we click on the new post link the template should come with this set of default custom fields with default values and admin can change them if he/she want to change any default value.

Read More

i know that there are few plugins, but i do not want to use those plugins in mean time i also have to take care that this new functionality should not break any thing as we already have thousands of published posts and i do not want them to get affected by this functionality.

Any suggestion or pointer in this regard will really be helpful.

Related posts

Leave a Reply

4 comments

  1. I’d recommend creating your own plug-in for storing and updating these options.

    To add the defaults, simply use the add_option function and to pull them into your custom metabox, when you check for the custom post meta, if it isn’t found, echo out the appropriate option using get_option.

    You can always just hard-code the values into the add_option statement, but if you make a small plug-in with a page where you can edit them, you’d possibly save yourself time and trouble in the future if you ever need to update the defaults.

    Let me know if you need some help implementing this, I’ll need to take a look at your metabox code to help, though.

  2. Try using advanced-custom-fields plugin.

    advanced custom fields, you can create custom fields and assign some conditions for displaying the particular custom fields for specific post type or any other condition.

    You can use multiple types of custom fields as:

    1. Tab (Group fields into tabs)
    2. Text (type text, api returns text)
    3. Text Area (type text, api returns text with
      tags)
    4. WYSIWYG (a wordpress wysiwyg editor, api returns html)
    5. Image (upload an image, api returns the url)
    6. File (upload a file, api returns the url)
    7. Select (drop down list of choices, api returns chosen item)
    8. Checkbox (tick for a list of choices, api returns array of choices)
    9. Page Link (select 1 or more page, post or custom post types, api returns the url)
    10. Post Object (select 1 or more page, post or custom post types, api returns post objects)
    11. Date Picker (jquery date picker, options for format, api returns string)
    12. True / False (tick box with message, api returns true or false)
    13. Relationship (select and order post objects with a tidy interface)
    14. Color Picker (Farbtastic!)
    15. Repeater (ability to create repeatable blocks of fields!)
    16. Flexible Content (ability to create flexible blocks of fields!)
    17. Gallery (Add, edit and order multiple images in 1 simple field)

    You can find the documentation here.