Home › Forums › Back End › WordPress check other posts on publish › Re: WordPress check other posts on publish
June 27, 2011 at 7:36 am
#82340
syron1988
Member
Got a new version ,but I cannot get the update_post_meta work properly… After setting it to current background, I want the checkbox beeing unchecked again.
Here is my code:
function set_background( $post_ID ) {
global $posts, $post;
$option_name = 'my_backround' ;
$newvalue = $post_ID ;
//$postMeta = get_post_meta( $post_ID, '_cf_background_set', true );
//$newvalue = $postMeta;
update_post_meta( $post_ID, '_cf_background_set', 0, 1 );
if (isset($_REQUEST)) {
if ( get_option( $option_name ) != $newvalue ) {
update_option( $option_name, $newvalue );
} else {
$deprecated = ' ';
$autoload = 'no';
add_option( $option_name, $newvalue, $deprecated, $autoload );
}
}
}
add_action('publish_background', 'set_background');
add_action('save_background', 'set_background');