Reputation: 650
In wordpress title of the page is divided by |
. In my project On my front page title is fine (e.g. title | title). But in the inner pages title is not complete. Its not showing second part after | (symbol).
I have tried
<title><?php bloginfo('name'); ?> | <?php is_front_page() ? bloginfo('description') : wp_title(''); ?></title>
But it does not show anything after | symbol (in inner pages).
I have also tried wp_title()
. But its start showing url in the title instead of name/title. What else I can try to make my title correct
Upvotes: 1
Views: 340
Reputation: 650
I have fond a solution with the help of THIS POST
Just did little bit changes in the solution of that post and its working fine now.
<title><?php if (is_front_page()) { bloginfo('name');echo ' | ';bloginfo('description'); } elseif ( is_category() ) { single_cat_title(); echo ' - ' ; bloginfo('name'); }
elseif (is_single() ) { single_post_title(); }
elseif (is_page() ) { bloginfo('name'); echo ' | '; single_post_title(); }
else { wp_title('',true); } ?></title>
Upvotes: 0
Reputation: 11670
From codex:
<?php
if ( ! function_exists( '_wp_render_title_tag' ) ) :
function theme_slug_render_title() {
?>
<title><?php wp_title( ' ', true, 'right' ); ?></title>
<?php
}
add_action( 'wp_head', 'theme_slug_render_title' );
endif;
?>
Since Version 4.1, themes should use add_theme_support() in the functions.php file in order to support title tag, like so:
Upvotes: 2
Reputation: 11440
Your code
If it's printing {blog_title} | {blank}
it most likely means something is wrong with the Page title. In the WP Admin, ensure the Page you're viewing has a Title set.
Alternatively, an SEO plugin is conflicting with the title function - try disabling plugins one by one and see if it impacts the output.
References: Bloginfo, is_front_page, wp_title
Upvotes: 2