conditionally echo in meta box data loop

$val will never == ” here, because $val is holding your field name, not the data. also, use get_the_value to have it returned, the_value will just echo the data out. foreach ($values as $val) { if ($artinfo_mb->get_the_value($val) != ”){ $artinfo_mb->the_value($val); echo ‘<br />’; } }

Migrating from metaboxes to wp_editor()

It works just the same like a regular textarea with the exception of the data being escaped so when you call for the saved data just make sure to decode the html entities using html_entity_decode here is a very simple demo class, take a look at how the field is created. if (!class_exists(‘wp_editor_meta_box’)){ class wp_editor_meta_box{ … Read more

multi custom fields and taxonomy search

I’m not sure if I fully understand what you’re trying to do, but I always recommend the Advanced Custom Fields plugin to people looking to make custom fields more useful and intuitive. Great plugin with great support and documentation. It really opens up a lot of possibilities.

input radio ‘checked’ saves, but select option ‘selected’ doesn’t

It was a long way around to get there but you basically have a markup error. You didn’t name your select. You should have: <select id=”select-taxonomy” name=”<?php echo $name ?>”> // <– here is the change <?php foreach($terms as $term) { $id = $taxonomy.’-‘.$term->term_id; $value= (is_taxonomy_hierarchical($taxonomy) ? “value=”{$term->term_id}”” : “value=”{$term->term_slug}””); echo “<option id=’in-$id’ “. selected($current,$term->term_id,false) … Read more

Add metabox without the container

Use the action edit_form_after_title. Example: add_action( ‘edit_form_after_title’, function() { echo ‘Enter some text: <input type=text>’; }); See this answer for another example.

Why do Metabox use Nonces?

WordPress nonces are meant to prevent unauthorized execution of code. In the case of meta boxes, they are protecting you against malicious users potentially adding unauthorized meta-information to your posts and pages by forging POST requests. Why wouldn’t you want to use nonces?

Why does not my metabox save?

I notice a couple of things. First, your callback uses two parameters but you don’t ask for the second parameter when you hook it in. This: add_action( ‘save_post’, ‘kasparibi_left_menu_meta_save’ ); Should be: add_action( ‘save_post’, ‘kasparibi_left_menu_meta_save’ ,1 ,2 ); But, on the other hand, I don’t see where you use that parameter at all. Maybe I … Read more