WordPress Title Empty on Index Page

Here’s description from WordPress Codex about what happen when WordPress title empty when viewing index page/ homepage

If you are using a custom homepage with custom loops and stuff or a custom front-page, you will have an empty wp_title.

I recently encountered this problem on a client’s site. Homepage/Index page is using a static page (WP Dashboard > Settings > Reading > A Static Page > Front page)

Simple solution like this

Using a conditional to display site title when viewing homepage

<?php is_front_page()?bloginfo('name'):wp_title('');  ?>

Complete code like this

<?php is_front_page()?bloginfo('name'):wp_title(''); wp_title(''); ?>

Post/page outputs: Page Title

Homepagd outputs: Site Name


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: