Today I ran into a problem with the csv_tags() function. This is quite common in WordPress themes and lets the header.php create the keywords meta tag on the fly. But, one caveat, it’s usually used by creating the keywords from the tags on the page, and so only used on single post pages or pages.
Also, GRS has moved to use the NextGEN gallery plugin on the front page (and category pages). This has caused a bit of a problem since they now use a page as the front page. Since the posts on the front page are specifically coded to not display tags, the csv_tags() functions doesn’t work properly.
So I had to alter it, and thought a better way of doing this would be to check for the NextGEN gallery and use the alt text. Here is the new altered csv_tags() function:
function csv_tags() {
if (is_home() || is_front_page()) {
global $wpdb;
$results = $wpdb->get_results(‘SELECT alttext FROM wp_ngg_pictures WHERE galleryid = 1 AND exclude = 0′);
foreach ($results as $row) {
$csv_tags .= $row->alttext . ‘,’;
}
} else {
$posttags = get_the_tags();
foreach((array)$posttags as $tag) {
$csv_tags .= $tag->name . ‘,’;
}
}
echo ‘<meta name=”keywords” content=”‘.$csv_tags.’” />’;
}

















Comments