已为老胡 - 网络技术研究和生活琐事记录 - Keywords
type: channel
link: https://www.heyihu.com/tag/Keywords/
items: 填充WordPress的keywords和description

填充WordPress的keywords和description
type: item
date: 2010-06-21T17:45:04+08:00
description: 代码如下，用了substr截取文章前220个字符作为description，关键词keywords采用标签填充，则分类采用分类描述：<?php if (is_home()){ $description = "胡立业,争做“小胡”搜索引擎第一,知识收集,影音分享,搞怪娱乐,资源下载,热点追踪,生活记录"; $keywords = "小胡,pjblog,wordpress,windows7 sp1"; } elseif (is_single()){ if ($post->post_excerpt) {$description = $post->post_excerpt;}elseif( function_exists('substr')){$description = substr(strip_tags($post->post_content),0,220);}else { $description = $post->post_title;} $keywords = "胡立业"; $tags = wp_get_post_tags($post->ID); foreach ($tags as $tag ) { $keywords = $keywords . "," . $tag->name; } } elseif(is_category()){ $description = category_description(); } echo " ";?>