Give help. Get help.

  • # November 20, 2011 at 5:19 am

    Hi Guys,

    I’ve been wrestling with this all day and I can’t work out whats going wrong.

    I’ve got the custom meta boxes displaying; a text box and a drop down list, but I can’t get them to save their values to the database.

    Am I missing something really simple?? Any guidance would be really appreciated.

    Here’s my code:

    < ?php
    function at_post_meta (){
    global $post;
    $custom = get_post_custom($post->ID);
    $at_slider_featured = $custom["at_slider_featured"][0];
    $at_other_author = $custom["at_other_author"][0];

    < ?php

    function add_at_post_box(){
    "Post Details",

    function save_at_post_meta(){
    global $post;
    update_post_meta($post->ID, "at_slider_featured", $_POST["at_slider_featured"]);
    update_post_meta($post->ID, "at_other_author", $_POST["at_other_author"]);

    add_action( 'admin_init', 'add_at_post_box');

    add_action('save_post', 'save_at_post_meta');

    add_action('publish_post', 'save_at_post_meta');

    Any ideas would be greatly appreciated.



    # November 20, 2011 at 6:44 am

    @mtedwards from what I understand is you’ll need a nonce in there to validate @ save… Here’s a link on how I use the add_meta_box hook

    Hope that helps!

    # November 20, 2011 at 6:55 am

    @dhiggins Thanks so much… its getting late here (Australia) but I looked at your post and it looks like exactly what I need. Going to work through it in the morning.

    Thanks again.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.