Customizing WordPress the_title with add_filter

The issue is that you are mixing up the $title variables. $title is the parameter passed to the new_title function, but then you use it as an array: $title['custom_version']. Try this:

add_filter('the_title', 'new_title', 10, 2);
function new_title($title, $id) {
    if('custom_version' == get_post_type($id))
        $title="Application has been updated to v".$title;
    return $title;
}

I’d also highly recommend prefixing your function with a unique prefix because you may run into another plugin/theme using a function called new_title, which will reek havoc!

Leave a Comment