rewrite title format in header.php

Posted in: Newspaper
Post count: 28

hi,the default title format of the theme is Post Name|Site Name,how to change it to Post Name|Category Name|Site Name? And also when page lists ,make the title show Post Name – Page Count|Category Name|Site Name.

This is better for SEO and I am not very happy with ALL IN ONE SEO,so pls help. Thank you.

  • This topic was modified 11 years by winnieji.
Post count: 28

I already had this code below which can have the page number on title when there are page lists:

<title><?php
	global $page, $paged;
	$site_description = get_bloginfo( 'description', 'display' );
 	if ($site_description && ( is_home() || is_front_page() )) {
		bloginfo('name');
		echo " - $site_description";
	} else {
		echo trim(wp_title('',0));
		if ( $paged >= 2 || $page >= 2 )
			echo ' - ' . sprintf( __( '第%s页' ), max( $paged, $page ) );
		echo ' | ' ;
		bloginfo('name');
	}
?></title>

But don’t know how to make the title echo category name.

  • This reply was modified 11 years by winnieji.
Post count: 9544

When I used to do my own WordPress themes, I’d put in all the applicable coding and format in the header.php file and QED. However with modern themes with different kinds of headers, customizations, theme panels, etc., it can be a pain in the butt.

Frankly, I just use the Yoast WordPress SEO plugin the past 2 years, and this has worked perfectly for exactly what you’re trying to do. Really. If you only use it for that, it works very well. 🙂

Post count: 28

Thank you for the reply ChriS.But for me I only want to rewrite the title, using seo plugin is a so much waste. And,I don’t like that plugin:).I don’t think it is better for SEO than simply messing with <title> </title> in header.

  • This reply was modified 11 years by winnieji.
Post count: 6600

Hi,

You can try altering your code like this: http://screencast.com/t/YB0G2sfEaU

Thanks

Viewing 5 posts - 1 through 5 (of 5 total)
The forum ‘Newspaper’ is closed to new topics and replies.