You can use one of the status transition filter hooks for this:
In the function assigned to the hook, you change the status to publish
the previously featured post ( using e.g. $wpdb
).
Both actions are performed after saving the post, so you have to change the status in posts other than edited.
add_action( 'featured_commercials', 'se339582_single_featured', 10, 2 );
function se339582_single_featured( $post_id, $post )
{
global $wpdb;
$sql = $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_status="publish" "
." WHERE post_status="featured" AND id <> %d", $post_id );
$wpdb->query( $sql );
}
Update:
SQL for one featured post per category:
$taxonomy_slug = 'commercials';
$sql = $wpdb->prepare( "UPDATE {$wpdb->posts} p " .
" INNER JOIN {$wpdb->term_relationships} tr ON tr.object_id = p.id " .
" INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id " .
" SET p.post_status="publish" " .
" WHERE p.id <> %d AND p.post_status="featured" AND tt.taxonomy=%s AND tt.term_id = %d",
$post_id, $taxonomy_slug, $term_id
);