• Good day!

    function rm_martins_cpt_permalink_change($data, $postarr) {
    if ($data['post_type'] == 'video') {
                    $time = time();
     $data['post_name'] = md5($time);
     return $data;
     } else {
               return $data;
           }
    }
    add_filter('wp_insert_post_data','rm_martins_cpt_permalink_change',10,2);

    I found this code online. It’s working but every time I update my post, post slug keeps changing. I would like this function to only run if post is to be publish only.

    Thanks and God Bless!

    [Please post code snippets between backticks or use the code button.]

The topic ‘Auto Generate Post Slug’ is closed to new replies.