Set post name to post id
-
I am trying to set a custom post types name to be the id of the post but i cant get it to work
I tried this snippet
add_filter('the_title', 'add_id_to_title', 10, 2); function add_id_to_title($title, $post_id) { //use the id to check the post type and only add the id if it has a type of "post" if(get_post_type($post_id) == "message") $title = $post_id; return $title; }
But it does not set the post name it looks like it does on the post type page but name is just (Auto Draft)
i use pods to create the custom post type and have removed the title as it is not needed for my website.
The id is for moderation only
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Set post name to post id’ is closed to new replies.