WordPress: Jerome’s Keywords Modifications

I’m using Jerome’s Keywords plug-in for WordPress, but found that I didn’t want my entire list of Categories output to the meta keywords tag (it was a bit excessive and in my opinion, might push the limits of what a crawler will accept). The changes are simple and posted here in case you want to make them to your copy. For the function get_the_keywords() you can pass a boolean value (e.g., get_the_keywords(true); ) which indicates whether to include the categories in the keyword list. Default is to NOT include them.

N.B.This modification applies to version 1.3, it’s easy to adapt it to 1.4, and by 1.5 I think Jerome will already have included it.

function get_the_keywords($include_categories=false) {
	global $cache_categories, $post_meta_cache;
	
	$keywords = "";
	
	if (isset($cache_categories) && $include_categories) {
		foreach($cache_categories as $category)
			$keywordarray[$category->cat_name] += 1;
	}
	
	if (isset($post_meta_cache)) {
		foreach($post_meta_cache as $post_meta)
			$keywordarray[
	                 $post_meta[KEYWORDS_META][0] ] += 1;
	}
	
	if (isset($keywordarray)) {
		foreach($keywordarray as $key => $count) {
			if (!empty($keywords))
				$keywords .= ",";
			$keywords .= $key;
		}
	}
	
	return ($keywords);
}

2 Responses to “WordPress: Jerome’s Keywords Modifications”

  1. NoCategories » Blog Archive » Technorati Tags Says:

    […] I’d be saying that my essays are poems and essays — and that’s stupid. Acme Technologies Zeitgeist has published a fix for the keyword […]

  2. wayne Says:

    I exchanged some email with Jerome last week and we discussed my mod. to his plugin. he wrote:

    Hmmm… At the time it made sense — basically I wanted the home page to include all categories even if the posts displayed only covered a few categories. However, it does make more sense to use only the post categories for any other view. I guess I’ll have to add an option that allows you to include all, current or none. Does that sound good to you?

    He’s going to incorporate my suggestions, and I hope, also look at making the plugin work within wordpress Pages.

Leave a Reply

You must be logged in to post a comment.