I want to change all titles of posts from a specific category to a static one and don't want to change the rest. I have tried this code (based on this question but it doesn't work:
add_filter('wp_insert_post_data', function($data, $postarr) {
$args = array( 'category' => 36 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :
$data['post_title'] = "New static title @ CurrentDate";
$return $data;
}, 10, 2);
What is wrong? Thanks!