What do the numbers mean at the end of add_action(‘save_post’)…?
The 10 is the priority (relative to other added actions) and the 2 is simply the number of arguments that my_save_post() will accept. See the codex.
The 10 is the priority (relative to other added actions) and the 2 is simply the number of arguments that my_save_post() will accept. See the codex.
Please take some time to read the Codex. the_ID echos content. That means that the ID is never being passed to get_post_meta. It is just echoed in place. From the same Codex Page: Note: This function displays the ID of the post, to return the ID use get_the_ID(). So, use get_the_ID instead. Second problem… quote … Read more
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
From what I thought was a duplicate, we get a class to render the meta box in the Nav-Menus page. Then I used this core function to render the meta box contents. It works ok, but it’s displaying some notices and may need a good cleanup. It’s too much code to parse right now and … Read more
I consider this question to be borderline unanswerable. It really depends on context. In your example $post is whatever that global has been set to. That is pretty general, pretty obvious, and not really saying much but without knowing the context in which this code executes it is hard to give a better answer. That … Read more
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.
Separate the allowed values in a function: function get_allowed_values() { return array(‘one’, ‘two’, ‘three’); } In your metabox: foreach ( get_allowed_values() as $item) {} In your validation handler: if ( isset( $_POST[‘select_meta’] ) and in_array( $_POST[‘select_meta’], get_allowed_values() ) )
Ok, you do have a typo : add_action(‘save_post’, ‘vs_save_custom_meta’); should be : add_action(‘save_post’, ‘vs_save_excerpt_meta’); So you meta box does not have a valid callback. Change this and it will work ^^
There is a way to put that meta box after the title. There is a hook called edit_form_after_title. If you look at the source there is no hook earlier than that that isn’t much too early– outside of the <form tag. The following does move that box to the location after the title… function generic_box() … Read more
I tested your code and this ended up working for me: case ‘multiselect’: echo ‘<select name=”‘.$field[‘id’].'” id=”‘.$field[‘id’].'”>’; foreach ($field[‘options’] as $option) { echo ‘<option’, $meta == $option[‘value’] ? ‘ selected=”selected”‘ : ”, ‘ value=”‘.$option[‘value’].'”>’.$option[‘label’].'</option>’; } echo ‘</select><br /><span class=”description”>’.$field[‘desc’].'</span>’; break; For the Field Array I just added another option with a blank value and a … Read more