How to store the value of a custom field dropdown select for post referencing?

selected() was big help for setting a default value. The rest I found in this brilliant meta box tutorial: http://code.tutsplus.com/tutorials/how-to-create-custom-wordpress-writemeta-boxes–wp-20336 with examples for text input, checkboxes and dropdown. Also Custom post type’s slug gets wrong when adding a custom meta box explained me how to correctly handle the current post object so it doesn’t get … Read more

save_post action only when creating a new post

The save_post action also passes three parameters to your callback, one of which being $update which denotes whether the post being saved is an existing post or not. /** * Save post metadata when a post is saved. * * @param int $post_id The post ID. * @param post $post The post object. * @param … Read more

save_post action firing before I publish / save the post

A draft or “blank” is saved as soon as you start to create a new post. Those new posts have the post_status of auto-draft. Check for that to prevent your callback from firing on those “blank” post saves. function update_test( $post_id, $post ) { if (isset($post->post_status) && ‘auto-draft’ == $post->post_status) { return; } update_post_meta($post_id, ‘copied’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)