php - Wordpress get custom meta box checkbox checked -


I have a custom custom post type with custom meta box, I can save 3 checkboxes with the meta box. But how do I get data from those checkboxes in my theme?

This is my function

  function social_services ($ post) {// Post using Post Meta Value Other values ​​from our save function in the $ custom = get_post_meta ($ Post-> ID, '_social_services', true); ? & Gt; & Lt; Input type = "checkbox" id = "social_services_soundcloud" name = "social_services []" value = "soundcloud" & lt ;? Php echo (in_array ('soundcloud', $ custom))? 'Check = "check"': ''; ? & Gt; & Gt; & Lt; For label = "social_services_soundcloud" & gt; & Lt; / Label & gt; Soundcloud & lt; Br> & Lt; Input type = "checkbox" id = "social_services_facebook" name = "social_services []" value = "facebook" & lt ;? Php echo (in_array ('facebook', $ custom))? 'Check = "check"': ''; ? & Gt; & Gt; & Lt; Label = "social_services_facebook" & gt; & Lt; / Label & gt; Facebook & lt; Br> & Lt; Input type = "checkbox" id = "social_services_twitter" name = "social_services []" value = "Twitter" & lt ;? Php echo (in_array ('twitter', $ custom))? 'Check = "check"': ''; ? & Gt; & Gt; & Lt; Label = "social_services_twitter" for & gt; & Lt; / Label & gt; Twitter & lt; Br> & Lt ;? Php} function save_extra_fields () {global $ post; If (isset ($ _POST ['social_services'])) {$ custom = $ _POST ['social_services']; $ Old_meta = get_post_meta ($ post-> ID, '_social_services', true); // Update Post Meta (! Empty ($ old_meta)) {update_post_meta ($ post-> ID, '_social_services', $ custom); } Other {add_post_meta ($ post-> ID, '_social_services', $ custom, true); }} // update_post_meta ($ post-> ID, "manufacturer", $ _POST ["creator"]); } Add_action ('save_post', 'save_extra_fields');   

Edit: I've decided to do this with:

  if (in_array ('soundcloud', get_post_meta ($ post- & gt; id, '_social_services' true)) == true) {// show the content here "soundcloud" echo; }   

I have decided with it:

 < Code> if (in_array ('soundcloud', get_post_meta ($ post- & gt; id, '_social_services', true)) == true) {// show content here "soundcloud" echo; }    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -