wordpress
This site is a portfolio of Ray . Hope you enjoy it!
故事板,分镜头,storyboard,电影分镜,分镜师,storyboard artist
-1
archive,paged,tag,tag-wordpress,tag-126,paged-2,tag-paged-2,elision-core-1.0.5,woocommerce-no-js,ajax_updown_fade,page_not_loaded,qode-child-theme-ver-1.0.0,qode-theme-ver-4.1.1,wpb-js-composer js-comp-ver-5.7,vc_responsive
Title Image

wordpress Tag

首页和文章显示keywords和description.

  |   Geek   |   No comment

13-3-3 sbw更改主题文件header.php*************************************************** 更改了header.php.让首页和文章显示keywords和description. 在源文件中删除了原文件的<keywords>和<description>表达式 更改为: <?php //如果是首页 if (is_home()){ $keywords = "你网站首页的关键字,自己修改吧"; $description = "你网站首页的描述,自己修改吧"; } //如果是文章页 elseif (is_single()){ //默认使用文章页添加关键字 $keywords = get_post_meta($post->ID, "keywords", true); //如果为空,使用标签作为关键字 if($keywords == ""){ $tags = wp_get_post_tags($post->ID); foreach ($tags as $tag){ $keywords = $keywords.$tag->name.","; } //去掉最后一个, $keywords = rtrim($keywords, ', '); } //默认使用文章页添加描述 $description = get_post_meta($post->ID, "description", true); //如果为空,使用文章前100个字作为描述 if($description == ""){ if($post->post_excerpt){ $description = $post->post_excerpt; }else{ $description = mb_strimwidth(strip_tags(apply_filters('the_content',$post->post_content)),0,200); } } } //如果是页面,使用页面添加的关键字和描述 elseif (is_page()){ $keywords = get_post_meta($post->ID, "keywords", true); $description = get_post_meta($post->ID, "description", true); } //如果是分类页,使用分类名作为关键字,分类描述作为描述 elseif (is_category()){ $keywords...

Read More