Tweak -head meta desc pluging
-
hi,
I read about tweakin head meta desc so that you can put a custom description for your main page.
——-
The tweak says that if the string-length of the description tag = 0, then it reverts to a separate description tag. Thus on your index.php page or any other page where there’s no specific excerpt to use, it’ll revert to your default description. The tweak is as follows:if ( strlen( trim( $description )) == 0 ) {
$description = ‘Hotdogs rock my world… Yum’;
}
—————
I tried to modify the head meta desc plugin, but am getting a parsing error . See code below .
Can someone correct the error
thanks
——————————<?php
/*
Plugin Name: Head META Description
Plugin URI: http://guff.szub.net/head-meta-description/
Description: Insert HTML META description tag: excerpt/content brief for post/Page, description for category, and blog tagline for everything else.
Author: Kaf Oseo
Version: R1
Author URI: http://szub.net/Copyright (c) 2005, Kaf Oseo (http://szub.net)
Head META Description is released under the GNU General Public
License: http://www.gnu.org/licenses/gpl.txtThis is a WordPress plugin (http://ww.wp.xz.cn).
*/function head_meta_desc() {
/* >> user-configurable variables */
$default_blog_desc = ”; // default description (setting overrides blog tagline)
$post_desc_length = 20; // description length in # words for post/Page
$post_use_excerpt = 1; // 0 (zero) to force content as description for post/Page
$custom_desc_key = ‘description’; // custom field key; if used, overrides excerpt/content
/* << user-configurable variables */if(is_single() || is_page()) {
global $wp_query;
$post = $wp_query->post;
$post_custom = get_post_custom($post->ID);
$custom_desc_value = $post_custom[“$custom_desc_key”][0];if($custom_desc_value) {
$text = $custom_desc_value;
} elseif($post_use_excerpt && !empty($post->post_excerpt)) {
$text = $post->post_excerpt;
} else {
$text = $post->post_content;
}
$text = str_replace(array(“\r\n”, “\r”, “\n”, ” “), ” “, $text);
$text = str_replace(array(“\””), “”, $text);
$text = trim(strip_tags($text));
$text = explode(‘ ‘, $text);
if(count($text) > $post_desc_length) {
$l = $post_desc_length;
$ellipsis = ‘…’;
} else {
$l = count($text);
$ellipsis = ”;
}
$description = ”;
for ($i=0; $i<$l; $i++)
$description .= $text[$i] . ‘ ‘;$description .= $ellipsis;
} elseif(is_category()) {
global $cat, $cache_categories;
foreach($cache_categories as $category) {
if($cat == $category->cat_ID) {
$description = trim(strip_tags($category->category_description));
}
}
} else {
$description = get_bloginfo(’description’);
}
if ( strlen( trim( $description ) ) == 0 ) {
$description = ‘Hotdogs rock my world… Yum’;
}echo “\n�;
}add_action(’wp_head’, ‘head_meta_desc’);
?>
The topic ‘Tweak -head meta desc pluging’ is closed to new replies.