Custom Taxonomies Terms as Post Title for Custom Post Types upon Publishing

I’ve pieced together a solution. Let me know if it’s what you need:

add_filter('the_title','term_filter',10,2);
function term_filter($title, $post) {
    $post = get_post($post) ;
    if($post->post_type === 'special_post_type') {
        $terms = wp_get_object_terms($post->ID, 'taxonomy');
        if(!is_wp_error($terms) && !empty($terms)) {
            $title = $terms[0]->name;
        }
    }
    return $title;
}

Basically, I’m using a filter for the title that checks what post type the title is from. If it is the correct type, the title is replaced by the first term of your taxonomy that is connected to that post.

Ask me any questions if something isn’t clear!

Leave a Comment