Conditional delete metadata does not works

Try applying these and your code might work:

  1. Looking at the expressions $type_of_running == 'manually_run' and $type_of_running == 'planned_run', where you’re expecting get_post_meta() to return a single meta value, you should then set the 3rd parameter to true:

    // Set the 3rd param to true to get a single meta value.
    $type_of_running = get_post_meta($post_id, 'spusteni_dotazovani', true);
    
  2. metadata_exists() requires 3 parameters, i.e. the meta type (e.g. post for post meta or term for term meta), the “object” ID (e.g. post ID or term ID) and the meta key, so make sure you pass the correct parameters like so:

    if(metadata_exists('post', $post_id, 'datum_a_cas_planovaneho_spusteni')) {
        delete_post_meta($post_id, 'datum_a_cas_planovaneho_spusteni');
    }
    

    and

    if(metadata_exists('post', $post_id, 'running_status')) {
        delete_post_meta($post_id, 'running_status');
    }