Le titre de la question dit tout. En ce qui me concerne, je viens de m'en tenir au code par défaut de l'un des modèles fournis avec WordPress:
<title><?php
/*
* Print the <title> tag based on what is being viewed.
*/
global $page, $paged;
wp_title( '|', true, 'right' );
// Add the blog name.
bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
echo " | $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
echo ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) );
?></title>
Est-ce que l'un d'entre vous utilise un code différent pour cela?
Le mien est:
function getDocumentTitle($separator = " « "){
$title = get_bloginfo('name');
$desc = get_bloginfo('description');
if(is_front_page() && is_home() && !empty($desc)){
$title .= $separator.$desc;
}elseif(is_home() || is_singular()){
$id = $GLOBALS['wp_query']->get_queried_object_id();
if($meta = get_post_meta($id, 'title', true)) $title .= $separator.$meta;
$title .= (empty($meta) && is_front_page() && !empty($desc)) ? $separator.$desc : $separator.get_post_field('post_title', $id);
}elseif(is_archive()){
if(is_category() || is_tag() || is_tax()){
$term = $GLOBALS['wp_query']->get_queried_object();
$title .= $separator.$term->name;
}elseif(is_author()){
$title .= $separator.get_the_author_meta('display_name', get_query_var('author'));
}elseif(is_date()){
if(is_day())
$title .= $separator.sprintf(_a('Archive for %s'), get_the_time(apply_filters('doc_title_archive_day_format', 'F jS, Y')));
elseif(get_query_var('w'))
$title .= $separator.$separator.sprintf(_a('Archive for week %1$s of %2$s'), get_the_time('W'), get_the_time('Y'));
elseif(is_month())
$title .= $separator.sprintf(_a('Archive for %s'), single_month_title(' ', false));
elseif(is_year())
$title .= $separator.sprintf(_a('Archive for year %s'), get_the_time('Y'));
}else{
$title .= $separator.post_type_archive_title('', false);
}
}elseif(is_search()){
$title .= $separator.sprintf(_a('Search results for %s'), '"'.get_search_query().'"');
}elseif(is_404()){
$title .= $separator._a('404 Not Found');
}
// paged?
if((($page = $GLOBALS['wp_query']->get('paged')) || ($page = $GLOBALS['wp_query']->get('page'))) && $page > 1 && !is_404())
$title .= $separator.sprintf(_a('Page %s'), $page);
// comment page?
if(get_query_var('cpage'))
$title .= $separator.sprintf(_a('Comment Page %s'), get_query_var('cpage'));
// apply the wp_title filters so we're compatible with plugins
return apply_filters('wp_title', $title, $separator, '');
}
<title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' :: '; } ?><?php bloginfo('name'); if(is_home()) { echo ' :: '; bloginfo('description'); } ?></title>
http://www.nathanrice.net/blog/ultimate-guide-to-wordpress-seo-optimized-titles/
Travaille pour moi :)
J'essaie d'éviter les plugins dans la mesure du possible.