Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress – modify title tag. Reply To: WordPress – modify title tag.

#242599
gulliver
Participant

Thanks, Ilan.

Rather than a function, I’d been using conditionals within the title element of the header.php – an edited example of which is below.

<title><?php

// Set <title> tag based on what is being viewed.

global $page, $paged;

// Add the site name and separator.
bloginfo('name'); echo ' | ';

// Add the site description for the front page.
$site_description = get_bloginfo('description', 'display');
if ($site_description && (is_front_page())) echo "$site_description";

// Show page title on posts page.
if (is_home()) wp_title('');

// Title for 404.
if (is_404()) echo 'file not available';

// Add a page number if necessary:
if ($paged >= 2 || $page >= 2 ) echo ' ' . sprintf( __('(page %s)'), max($paged, $page) );

// Show page title.
if (is_page()) wp_title('');

//else bloginfo('name');

?></title>