WordPress wp_title function returns empty on homepage

Hey everyone! I just started working with WordPress and I’m using the latest version. I ran into this weird issue where the wp_title function works perfectly on all my pages but completely fails on the main homepage. It just shows nothing at all.

I tried searching online but most solutions I found were for much older WordPress versions and don’t seem to apply anymore.

Here’s the code I’m using in my header:

<title><?php wp_title('- My Awesome Site', true, 'right'); ?></title>

I know I could just hardcode the homepage title but that feels like a hack. Has anyone else experienced this? What’s the proper way to handle homepage titles in modern WordPress? Any help would be appreciated!

wp_title has been quirky with homepages for ages tbh. Quick fix is just check if your theme’s functions.php has the blog name and tagline settings properly configured. sometimes wordpress pulls from there for the homepage title instead of wp_title. also make sure your reading settings are set correctly - like if you have a static homepage vs blog homepage, that affects how wp_title behaves.

WordPress deprecated wp_title in favor of the document title support feature starting from version 4.1. You should add add_theme_support('title-tag'); to your functions.php file and remove the title tags from your header.php entirely. WordPress will then automatically generate proper titles for all pages including the homepage. I discovered this when updating an old client site last year and it solved the exact same problem you’re having. The title-tag feature uses the site name from your WordPress settings for the homepage and automatically formats page titles for other pages. Much cleaner than manually handling conditionals and it follows current WordPress standards.

This is actually expected behavior for wp_title on the homepage in newer WordPress versions. The function was designed to return empty for the front page since it assumes you want to handle the homepage title differently from other pages. I ran into this exact same issue about a year ago when migrating an older site. The cleanest solution is to add a conditional check in your header template. You can modify your code like this: <title><?php if (is_front_page()) { echo 'My Awesome Site - Homepage Description'; } else { wp_title('- My Awesome Site', true, 'right'); } ?></title>. This way you maintain control over your homepage title while still using wp_title for all other pages. It’s not a hack, it’s actually how WordPress expects you to handle this situation in modern themes.