122 responses to “How to Create A Custom WordPress Meta Box Instead of Using WordPress Custom Fields”

  1. Dennis A.

    I got an problem with the “function save_details(){
    global $post;
    update_post_meta($post->ID, “example”, $_POST["example"]);”.

    Sometimes it just don’t save it, after I click “Update post”, it gone.

    Any ideia?

  2. Rs245

    Does the custom meta box appear for all posts and page dashboards in the admin? Can I have the meta box(es) appear in only certain type of pages?

  3. Alshe Dupur


    Thanks for a great tutorial. Everything is work for me. But there is one problem… how I add a select box in meta.php ? I add like:

    Current Status

    <option value="Pending">Pending
    <option value="In Process">In Process
    <option value="Shipped">Shipped
    <option value="Delivereds">Delivered

    Choose Status

    but its not work. Please tell me how I add select, radio & checkbox ?

    Thanks again.

  4. Victor Haglund

    Thank you very much for this tutorial, you have just saved med allot of time on a project Im working on.

    Wish you a great day and thank you again for your time and making your knowledge available to the rest of us.

    Best regards Victor

  5. Ian

    Awesome! You saved me research time so now I can work on modifying this to suit my needs. It’s working perfect for me and retrieving _my_meta in the template file. Just a little modification and parsing and this is perfect for adding meta key words to the head of any page template.

  6. Brian

    This is great.. I have one question.. how do I add the parts to my post within the loop..

    I tried something this but it didn’t work

  7. Christian Laugesen


    Thanks for a great insight to metaboxes!!
    However I would like to use the standard:

    ID,’metaA’,true) ) : ?>
    ID, ‘metaA’, true) ?>

    How does that work with your method?

    Kind regards

  8. Christian Laugesen

    And without coding ;o)

    if ( get_post_meta($post->ID,’dato1′,true) ) :
    echo get_post_meta($post->ID, ‘dato1′, true)

  9. Carina

    trying to get the output of one of my text areas to display as a list of links. here’s what i got but it isn’t working. please help. thanks!

    ID, ‘_presentation_title["links"]‘, true);
    $source = explode(“\n”, $source); ?>

    <? for($i = 0;$i
    <a href="”>

  10. Carina

    oh i’m guessing my code wasn’t displaying. here’s the link i got the code from and just replaced CUSTOM_FIELD_NAME with _presentation_title["links"]

    but it’s still not outputting anything.

  11. Carina

    it took me forever to figure the code out above, it’ll take me forever x2 to figure wpalchemy lol i’ll try it out though. do you think i’ll be able to output a list of links like the link i showed you earlier?

  12. MJ

    where to use this comment ??
    i mean in which file ??

    $my_meta = get_post_meta($post->ID,’_my_meta’,TRUE);
    echo $my_meta['name'];
    echo $my_meta['description'];

  13. Katie Okolita

    Wonderful tutorial. Worked perfect for me.

  14. Ashok


    Everything is work for me.Thanks for a great tutorial.

  15. Michel


    This is awsome. It works like a charm.
    So I’m using it!

    However I would like to extend the fields listed in the meta box. I do this in the mets.php file. Every field I create works however I come across one thing that I can’t seem to get working.

    I want to add an upload-file field so the user (CMS-end not front-end) can upload a image.
    I created the field and I can select the file I would like to upload. Now I need a button that sais “Upload”. The problem is not how to create the button but the problem is how to upload the file.

    Maybe this has nothing to do with your script and it should be done with some PHP, but I hoped you have a solution for me!

    Thnx in advance.
    Oh and did I mention that your tutorial is Awsome!


  16. hookedonweb

    When I update a page the metabox data is not saved.

    I made a few basic changes that I assume should not affect the ability to save.

    Instead of running this as part of a theme I added it to a plugin, so the changes I made are: I include the main.php file from may plugin, I changed the path from the theme dir to the plugin dir.

    I metabox shows up, the css is applied, it works like normal but I can not save the metabox data.

    I am on wordpress 3.4.2

  17. bhadresh Ganjawala

    for this document of the wp meta box
    this is work grate

  18. John

    For adding the files through wordpress meta box. See full tutorial at: http://wordpressapi.com/2010/11/22/file-upload-with-add_meta_box-or-custom_post_type-in-wordpress/

  19. Vinoth Kumar

    Looks good, but adding combobox is quite difficult, Hope this article may helpful for adding combo box in meta boxes area. http://buffercode.com/simple-technique-add-custom-meta-box-wordpress-admin-dashboard/

1 3 4 5

Leave a Reply