• I wrote my own function to remove the comma from a meta value in the database. But the function doesn’t work.

    After a research i know i can use update_post_meta(); But nothing happend. What am i doing wrong?

    This is my code so far:

    add_action('wp_insert_post', 'deleteCommaDB');
    
    function deleteCommaDB($post_id){
        $price_key = 'price';
        $getPrice = get_post_meta($post_id, $price_key, true);
        $newPrice = str_replace(array(','), '' , $getPrice);
        update_post_meta($post_id, $price_key, $newPrice, true);
        return true;
    }

    Thanx!,

  • The topic ‘How to update a meta value to the database’ is closed to new replies.