Walker News

Update WP_TITLE To Display Blog Name On The Right

For those who have upgraded WordPress powered blogs to WordPress 2.5 and having the blog name appears on the right hand of post title, now is the time to update WordPress theme files that using WP_TITLE template tag.

On most WordPress themes, the header.php is usually the only PHP files that calls WP_TITLE function.
According to WordPress Codex, WordPress 2.5 introduces a new function parameter (i.e. seplocation) to WP_TITLE:
function wp_title($sep = '-', $display = true, $seplocation = '') {
       // Determines position of the separator
        if ( 'right' == $seplocation )
                $title = $title . $prefix;
                $title = $prefix . $title;

The seplocation allows WordPress theme designer to fix the blog name to appears on either left (default) or right, in addition to the character (i.e. separator) used to separate the blog name and post title.

Before there is seplocation parameter, I used to modify wp-includes/general-template.php (one of the WordPress core files) to fix “Walker News” on the right hand of each post titles.

Having said that, now everyone who prefers post title comes first then followed by blog name can remove plugin installed for this purpose or modification made to general-template.php file.
The WordPress powered blog is easier to maintain, as the modular concept breaks it down into three components:
  • core files (the engine of WordPress powered blogs),
  • plugins (the extensions build on top of WordPress core engine to facilitate features and creativities enrichment)
  • themes (the fashion or costume of WordPress powered blogs)

By keeping the WordPress core files intact, most general users could have less (or none) hassles to perform subsequent WordPress version upgrades.

Thus, fix the blog name appearance location in theme files (header.php) keeps the next WordPress version upgrade easier and less worries.

How to display blog name on the right hand of post title in WordPress powered blog?

Open the header.php file of WordPress theme, search for the wp_title() function call and put in the three parameters value that corresponding to separator character, display blog name (Boolean flag) and blog name appearance location.

For example, to display blog name on the right of post title and using dash character as separator, update the wp_title call in header.php theme file as this:
<title><?php wp_title('-',true,'right'); ?><?php bloginfo('name'); ?></title>

After saving the changes, press CTRL+F5 to force browser refresh the cached content and verify the effect.

Custom Search

2018  •  Privacy Policy