Post edited 11:47 pm – June 23, 2009 by tekiedude
I made some modifications to the pack and would like to suggest that you add the option to write descriptions for gallery attachments. It might be helpful to others and perhaps be added as a new feature
Here's code I added to function rewrite_title right before the is_single() test
} else if (is_attachment()) { //if an attachment get post parent description
$title = get_the_title($post->post_parent).” “.$post->post_title.” – “.get_option('blogname');
$header = $this->replace_title($header,$title);
function get_all_keywords was modified like so:
//$id = $post->ID;
// $keywords_i = stripcslashes($this->internationalize(get_post_meta($post->ID, “keywords”, true)));
$id = (is_attachment())?($post->post_parent):($post->ID); // if attachment then use parent post id
$keywords_i = stripcslashes($this->internationalize(get_post_meta($id, “keywords”, true)));
further down
if (function_exists('get_the_tags')) {
//$tags = get_the_tags($post->ID);
$tags = get_the_tags($id); //use ID from above
further down
//$autometa = stripcslashes(get_post_meta($post->ID, “autometa”, true));
$autometa = stripcslashes(get_post_meta($id, “autometa”, true)); // use ID from above
further down
//$categories = get_the_category($post->ID);
$categories = get_the_category($id); //use ID from above
in the main function wp_head I added code to make the description unique so you don't get dinged by google for duplicate meta descriptions. Right before this line add the code below and change the line
$meta_string .= sprintf(”<meta name=\\”description\\” content=\\”%s\\” />”, $description);
add
// added to produce diff meta descriptions in image gallery as images usually have numbers plus URLs tend to use dates
// get any numbers in the image name and append them to the description
if(get_option('aiosp_can')){
$url = $this->aiosp_mrt_get_url($wp_query);
if ($url) {
preg_match_all('/(\\d+)/', $url, $matches);
if (is_array($matches)){
$uniqueDesc = join('',$matches[0]);
}
}
$description .= ” “.$uniqueDesc;
}
hope this helps someone