Quick Tip: WordPress admin page title customization.

Tags

,

Recently I had to customize wordpress dashboard and other back-end related changes. I found every resource in wordpress codex and few in other blog sites. So I was able to do what I wanted to. Now I’m going to show you a quick tip how I changed wordpress admin page title.

It’s pretty simple all you have to do is add following code in your theme functions.php or some where else you prefer. I made a plugin for my project.


function my_page_title($my_title, $title){
$my_title = sprintf( __( '%1$s ‹ %2$s' ), $title, get_bloginfo('name'));
return $my_title;
}

add_filter(‘admin_title’, ‘my_page_title’, 10, 2);

This will return page title and your blog name. Now if you want to be more specific you can also do that. Like dashboard title can be different than others.


function my_page_title($my_title, $title){
if($title === 'Dashboard'){
$my_title = sprintf(__('%1$s ‹ %2$s — %3$s'), $title, 'Your Dashboard Title', get_bloginfo('name'));
}else{
$my_title = sprintf( __( '%1$s ‹ %2$s' ), $title, get_bloginfo('name'));
}
return $my_title;
}

add_filter(‘admin_title’, ‘my_page_title’, 10, 2);

Finally if you want to change the page title like below screenshot just do this.

wp


function my_custom_dashboard_name(){
if ( $GLOBALS['title'] === 'Dashboard' ){
$GLOBALS['title'] = __( 'My Custom Dashboard' );
}

return ;
}

add_action( ‘admin_head’, ‘my_custom_dashboard_name’ );

 

That’s it. Happy coding!

Follow

Get every new post delivered to your Inbox.

Join 941 other followers