cavka
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Hacks
In reply to: Custom metabox – strpos not finding the "-" character in the post titlearrrrgh. that’s my second stupid mistake today. I’m not even calling get_from_title()… *facepalm*
turns out, my code works fine if I’m actually using it.
Forum: Hacks
In reply to: Custom metabox – strpos not finding the "-" character in the post titleNo luck. It’s still giving me the full title (I have a title with both en and em dash and tried & #8211; with and without &, # and ; ans also for 8212). Just in case, this is the rest of the relevant code:
add_action('save_post', 'mytheme_save_data'); // Save data from meta box function mytheme_save_data($post_id) { global $meta_box; // verify nonce if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($meta_box['fields'] as $field) { $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ($new && $new != $old) { update_post_meta($post_id, $field['id'], $new); } elseif ('' == $new) { update_post_meta($post_id, $field['id'], get_the_title( $post_id )); } } }
Viewing 2 replies - 1 through 2 (of 2 total)