非常小黑 发表于 2013-11-18 03:24
楼主先去找到模板里面的category.php
然后看这段代码然后你去看header.php,添加(或者修改)这段代码大概 ...
只有在functions.php里有- //网站描述
- function dtheme_description() {
- global $s, $post;
- $description = '';
- $blog_name = get_bloginfo('name');
- if ( is_singular() ) {
- if( !empty( $post->post_excerpt ) ) {
- $text = $post->post_excerpt;
- } else {
- $text = $post->post_content;
- }
- $description = trim( str_replace( array( "\r\n", "\r", "\n", " ", " "), " ", str_replace( """, "'", strip_tags( $text ) ) ) );
- if ( !( $description ) ) $description = $blog_name . "-" . trim( wp_title('', false) );
- } elseif ( is_home () ) { $description = $blog_name . "-" . get_bloginfo('description') . dopt('d_description'); // 首頁要自己加
- } elseif ( is_tag() ) { $description = $blog_name . "'" . single_tag_title('', false) . "'";
- } elseif ( is_category() ) { $description = single_cat_title('', false) . "'";
- } elseif ( is_archive() ) { $description = $blog_name . "'" . trim( wp_title('', false) ) . "'";
- } elseif ( is_search() ) { $description = $blog_name . ": '" . esc_html( $s, 1 ) . "' 的搜索結果";
- } else { $description = $blog_name . "'" . trim( wp_title('', false) ) . "'";
- }
- $description = mb_substr( $description, 0, 220, 'utf-8' ) . '..';
- echo "<meta name="description" content="$description" />\n";
- }
复制代码
|