SEO WordPress

Add Custom Titles for Tags and Categories in WordPress

The Best WordPress SEO Plugin? A combination of two.

All in One SEO Pack (AIOSEO) is the leader in WordPress SEO plugins. It offers great functionality and simple integration into the process of writing a post. AIOSEO is not a perfect plugin, however, because it lacks some very important functionality:

  • Custom category title tags
  • Custom tag title tags
  • Mass editing of page, post, tag and category title tags/slugs

The plugin that has all of the features above (but lacks AIOSEO features) is SEO Title Tag, an imperfect but elegant solution to the list above.  This article shows how to use both plugins and have them combine forces to create a powerful solution for getting custom titles on all your site’s pages.

Getting All in One SEO Pack and SEO Title Tag to play well together

The goal is this: when displaying a tag page, category page, or a post with SEO Title Tag title, use SEO Title Tag’s generated title. Otherwise, let All in One SEO Pack generate titles.

Add the following code to your theme’s functions.php file, or your Thesis Theme’s custom_functions.php file:

function kws_check_title_conflict() {
	function kws_get_seo_title() { // Find out whether the title should be rewritten
		if(is_singular()) { // For some reason, get_seo_title_tag() kills WP if it's singular and not active on post/page, so this function looks janky
			global $post;
			$custom_title_key = get_option("custom_title_key");
			$post_custom = get_post_custom($post->ID);
			$custom_title_value = trim($post_custom["$custom_title_key"][0]);
			if(!empty($custom_title_value)) { return get_seo_title_tag(); }
		else {
			// Don't return a custom title if it's just the category name (SEO Title Tags default)
			if(function_exists(get_seo_title_tag) && get_seo_title_tag() && (is_category() && get_seo_title_tag() != single_cat_title("", false)) || (is_tag() && get_seo_title_tag() != single_tag_title("", false))) {
				return get_seo_title_tag();
		return false;

	if(kws_get_seo_title()) { // If there's a SEO Title Tags title,
		global $aioseop_options;
		$aioseop_options['aiosp_rewrite_titles'] = false;  // turn off AIOSEO Pack title rewriting
		add_action('wp_title', 'kws_get_seo_title', 1, 1); // and update the page's title
	} else {
		return false;
add_action('wp', 'kws_check_title_conflict', 1);

Customize every title tag on your site

Break free from the %category_title% | %blog_title% SEO doldrums!

Now, using a combination of All in One SEO and SEO Title Tags, you can have custom page titles, tag titles, and category titles for every page on your website. This means that you can optimize every page title.

In addition, use the Katz Web Services Rich Text Tags plugin so that you will have high-SEO value tag descriptions as well…making your site super-optimized!

Did this make your life easier? Was this information worth a buck?
Donate with PayPal (Much appreciated!)

17 replies on “Add Custom Titles for Tags and Categories in WordPress”

Hi Zack,
Thanks for this interesting post. SEO Title indeed seems to be a great plugin and I would like to use it exactly as you suggest it, ie. in combination with AIOSEO. However, there are many posts on the SEO Title plugin’s page claiming that SEO Title Tag caused that their custom fields became completely broken.
I’m using pretty many custom fields on my webpage too and the very last thing I want to experience is that they would get broken (as many people complain about SEO Title).
I was wondering if you have any idea about this or if there is any other (safer) way of complete customization of title tags – especially for categories. I need special title tag for each category, but again, I’m afraid to turn on SEO title plugin.
At the moment, I’m using other plugin which puts content of category description to the title tag and it works well, but apparently, category description is useful for other things and it’s a kind of waste to use it just for title tags… My website is running on WP 2.8.6. It has many different plugins, as well as custom fields. Quite complex installation.
Many thanks for your help or any ideas in advance!

I really wish I could get SEO Title Tag to work, but no dice. Apparently, from what I’ve read and experience, it doesn’t work with WP 2.9.1 just yet. I really need to customize the category titles for my, uhhh, categories.
On another note, I’m in Fort Collins and I’m a total WordPress head, really focused on real estate web design using WP. So yeah, not too far from you on many accounts.

I just installed the SEO title tag and it’s working fine, except it did not show me all of my posts to edit all the tags. The ones I edited are edited and it is all working.  I have Thesis 1.7 and WP 2.92.
I wish there was better documentation on how to implement this though. I just learned about tag conjunction pages and they discussed using this plugin but I am still figuring this out.

The all in one plugin is great for seo and anyone who has a wp blog needs it. One other plugin we suggest is the related posts plugin to help build internal relevant backlinks.

I have activated the two plugin and added your code in my function.php but it returns me the error.

I think Dinesh is getting the same error I am. telling me Parse error: syntax error, unexpected T_FUNCTION, expecting ‘{‘ for this line in the code function kws_get_seo_title()
Can you help?

I am getting an error with the functions file. It is saying
Parse error: syntax error, unexpected T_FUNCTION, expecting ‘{‘ in /home/nutrit08/public_html/wp-content/themes/headless/functions.php on line 4
Can you help really need this to work.

I know this is a stupid question but where should I add the file to get both plugin to work together?

Great post and thread! I’ve had mixed success. I’m able to create custom tags etc but similar to Warner I’ve had trouble with my posts. In my case NONE of the posts are showing up? Anyone else run into this? I’m running WP 3.0.1. Thanks a bunch!

I’ve been beating my head against the wall trying to customize my category title tags. Gave this a try, adding the code to my functions.php and also making sure to update my header title tag as required by SEO Title Tag. I’m able to save a custom title via the Title Tag option under Tools — but it doesn’t affect the text in the actual title bar.

I’m on WP3.0.1, so I don’t know if the Title plugin is simply incompatible or what the problem might be. Any suggestions would be most welcome.

Comments are closed.