Dynamic Title for custom post types

I use something like this in my header.php:

<title> 
<?php 
    if(is_front_page())
        echo "Front Page Title";
    else if(is_404())
        echo "Page Not Found";
    else
        the_title();
    echo ' | '.get_bloginfo('name');  
?>
</title>

Check out Conditional Tags for more information.


As a Function() :

functions.php

function setTitle(){
    global $post;

    $title = get_the_title();
    $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );

    if(is_tax())
        $title = $term->name;
    else if(is_search())
        $title = "Search";
    else if(is_404())
        $title = "Page Not Found";


    if(is_singular('customCPT')){
        $terms = get_the_terms( $post->ID, 'customCPT' ); 
        $term = array_pop($terms);
        $title = $term->name.' '.$title;
    }

    echo $title.'  |  '.get_bloginfo('name');
}

Then in your header.php

<title><?php setTitle(); ?></title>