Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMatt Campbell
9,767 PointsMore then one meta box in the sidebar causes values to not be saved for second meta box
I've just spent the last 4 hours tearing my face off trying to work out what the hell has been going on with my 2 meta boxes in the side bar of a custom post type.
The first meta box worked great and is used for the shortcode of a slider.
The second had things like address in it.
Problem was, and I've discovered it now and resolved it, that...since adding the slider meta box above the address one, the address meta box would save a key in the database but wouldn't save the value aswell. So it would return blank entries. Going to the database and adding a value meant it would then work but that's hardly very good.
I want to know why did adding a second meta box as a standalone meta box break the first one? Is it something to do with the save function I'm using?
Seen here -
add_action('save_post', 'save_venue_meta');
function save_venue_meta($post_id){
if(isset($_POST['_venue_district'])){
update_post_meta($post_id, '_venue_district',
strip_tags($_POST['_venue_district']));
}
if(isset($_POST['venue_address'])){
update_post_meta($post_id, '_venue_address',
strip_tags($_POST['venue_address']));
}
if(isset($_POST['venue_phone'])){
update_post_meta($post_id, '_venue_phone',
strip_tags($_POST['venue_phone']));
}
if(isset($_POST['_slider'])){
update_post_meta($post_id, '_slider',
strip_tags($_POST['_slider']));
}
}
Now has all 4 inputs being saved as I've grouped the 4th into the original three and all is well.
Matt Campbell
9,767 PointsAlready done. I know it won't get me anywhere, been here long enough to know that the scrolling is never going to be put in place. I can still whinge though.
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 PointsThat's fine if you want to whine. The bad grammar and misspellings will make it so no one will even understand (I had to read this post a couple of times to really understand what you were mad about). Try sending the support a well thought out essay explaining why you think what you want should be implemented for hundreds of thousands of people that haven't really voiced a complaint about this. I think if you make an effort to really explain why this feature you would like would be worthwhile in the long-run, that they would definitely consider it.
Matt Campbell
9,767 PointsOh my God...I've deleted it. You happy now? Quit trolling my posts.
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 PointsLearn to take some criticism and don't act like every 12 year old who says trolling. Get tough skin because not everyone is going to be nice, honestly almost no one is unless your paying them. Programming is all about finding solutions on your own and challenging yourself to do better. Not getting mad at someone giving you a little criticism.
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 PointsAlas, good luck on your question.
1 Answer
Zac Gordon
Treehouse Guest TeacherMatthew Campbell did you get this resolved? Sorry for the late response.
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 PointsJonathan Becher
Full Stack JavaScript Techdegree Student 4,655 Pointsthere is a contact support link right next to the forum body. Use it instead of flaming in these forums, where it will get you no where.