i am working on save only on sticky post .
added this code as plugin .
add_action( 'draft_to_publish', 'only_one_sticky' );
add_action( 'future_to_publish', 'only_one_sticky' );
add_action( 'new_to_publish', 'only_one_sticky' );
add_action( 'pending_to_publish', 'only_one_sticky' );
add_action( 'publish_to_publish', 'only_one_sticky' );
function only_one_sticky( $post_id ) {
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( ! wp_is_post_revision( $post_id ) ) {
$post_id = $post_id->ID;
}
$sticky = ( isset( $_POST['sticky'] ) && $_POST['sticky'] == 'sticky' ) || is_sticky( $post_id );
if( $sticky ) {
$sticky_posts = array();
$sticky_posts_list = get_option( 'sticky_posts', array() );
// The Post IDs are stored in the options table as a single list, so we need to construct a new list with the future posts, plus the newly-published sticky post.
$new_sticky_posts_list = array();
foreach ($sticky_posts_list as $sticky_post) {
$postStatus = get_post_status ( $sticky_post );
if ( get_post_status ( $sticky_post ) != 'publish' || $sticky_post == $post_id ) {
array_push( $new_sticky_posts_list, $sticky_post );
}
}
update_option( 'sticky_posts', $new_sticky_posts_list );
}
}
i deactivate this plugin .
i notice .
1) created a new post - check stick to front
2) again update same post - stick to front unchecked (removed also from db options sticky_posts )
this happen on every post .
im also using custom theme and wpml plugin