- This topic is empty.
-
AuthorPosts
-
July 3, 2013 at 1:24 am #46064
asiek
ParticipantI posted a [discussion](https://css-tricks.com/forums/discussion/26306/wordpress-custom-fields-data-not-displaying-on-template#Item_6 “https://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 #141456asiek
ParticipantPlease Help >.<
July 3, 2013 at 1:00 pm #141457pixelgrid
Participantyour 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 togetherJuly 3, 2013 at 1:10 pm #141459asiek
Participant@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 #141460asiek
Participant@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 #141476asiek
ParticipantAnyone good with PHP mind taking a look at this for me Please?
July 3, 2013 at 6:30 pm #141479pixelgrid
Participantyou 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 #141481asiek
Participant@pixelgrid Thank you
July 3, 2013 at 11:20 pm #141488asiek
ParticipantI 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”) -
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.