Grow your CSS skills. Land your dream job.

Select Menu for Custom post Type does not save…

  • # July 3, 2013 at 1:24 am

    I posted a [discussion](http://css-tricks.com/forums/discussion/26306/wordpress-custom-fields-data-not-displaying-on-template#Item_6 “http://css-tricks.com/forums/discussion/26306/wordpress-custom-fields-data-not-displaying-on-template#Item_6″) the other day.
    Explaining that my Videos were not displaying on my Video page from my custom post type that I created using [this tutorial.](http://wp.tutsplus.com/tutorials/creative-coding/youtube-and-vimeo-video-gallery-with-wordpress/ “http://wp.tutsplus.com/tutorials/creative-coding/youtube-and-vimeo-video-gallery-with-wordpress/”)
    I thought I fixed the issue but it turns out the issue *wasn’t resolved.*

    Anyway, so I thought maybe the way I setup my CPT/Fields were messing things up.
    So I found another tutorial and redid the CPT and Fields, here is the new code//
    [http://pastebin.com/E5t6fcmn](http://pastebin.com/E5t6fcmn “http://pastebin.com/E5t6fcmn”)

    I was able to get my Video ID field to save, but when I select “Youtube” or “Vimeo”, then save, it just goes back to it’s default option “Select”.

    I am new to all of this WordPress PHP so I have no idea if the select menu code is correct…
    I’d appreciate any help to find the cause of this.

    # July 3, 2013 at 12:30 pm

    Please Help >.<

    # July 3, 2013 at 1:00 pm

    your problem might be this line

    if( $post->post_type == ‘revision’ ) return; // Don’t store custom data twice

    since you have already saved your post the second time is a revision so it just returns not updating the post meta.
    try commenting the whole line and if it works either make sure with javascript that every field is required or remove it all together

    # July 3, 2013 at 1:10 pm

    @pixelgrid I commented out the line, but the Selected Value is still not saving :(

    foreach ($videos_meta as $key => $value) { // Cycle through the $videos_meta array!
    //if( $post->post_type == 'revision' ) return; // Don't store custom data twice
    $value = implode(',', (array)$value); // If $value is an array, make it a CSV (unlikely)
    if(get_post_meta($post->ID, $key, FALSE)) { // If the custom field already has a value
    update_post_meta($post->ID, $key, $value);
    } else { // If the custom field doesn't have a value
    add_post_meta($post->ID, $key, $value);
    }
    if(!$value) delete_post_meta($post->ID, $key); // Delete if blank
    }

    # July 3, 2013 at 1:23 pm

    @pixelgrid The funny thing is that I’m using the same type of select menu from my events Post type, and that saves perfectly…
    But it just doesn’t want to work in my video’s post type :/

    # July 3, 2013 at 5:26 pm

    Anyone good with PHP mind taking a look at this for me Please?

    # July 3, 2013 at 6:30 pm

    you might find it better asking your question to http://wordpress.stackexchange.com/ .
    that forum is only for wordpress questions.
    you might find help quicker than here.

    # July 3, 2013 at 8:39 pm

    @pixelgrid Thank you

    # July 3, 2013 at 11:20 pm

    I was able to get assistance from someone via WordPress Stack Exchange :D

    You can check out the solution to the two issues here//
    [http://wordpress.stackexchange.com/questions/105256/select-menu-for-custom-post-type-does-not-save](http://wordpress.stackexchange.com/questions/105256/select-menu-for-custom-post-type-does-not-save “http://wordpress.stackexchange.com/questions/105256/select-menu-for-custom-post-type-does-not-save”)

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".