非常小黑 發表於 2013-11-18 03:24 0 N5 E6 S! D* t9 h! ~! x
樓主先去找到模板裡面的category.php
5 P. a4 Z! i! L6 x& O& d然後看這段代碼然後你去看header.php,添加(或者修改)這段代碼大概 ...
3 l, G8 X& Y- M- g只有在functions.php裡有- //網站描述
$ u2 R+ e% e. G u - function dtheme_description() {) T; N c6 H: w9 v9 R' `0 U- k
- global $s, $post;) e0 W0 s. ?9 c
- $description = '';
- p$ _/ o/ I) e: z - $blog_name = get_bloginfo('name');+ x0 h r8 ?5 E1 O" p! N
- if ( is_singular() ) {) Y) i$ t! p/ W3 p7 F! u% k
- if( !empty( $post->post_excerpt ) ) {: N7 \5 j' c; X& }( C) t% X
- $text = $post->post_excerpt;" v5 r% p8 C8 M n _
- } else {# a5 g- r" P" S# I, ]! ?
- $text = $post->post_content;
! T6 B" V0 u o$ {. k( p9 o - }6 d; I: r- Q% I+ g: G; s/ ^" F; y
- $description = trim( str_replace( array( "\r\n", "\r", "\n", " ", " "), " ", str_replace( """, "'", strip_tags( $text ) ) ) );
, M- z4 Z9 Y2 {. ?5 H* }1 s! p - if ( !( $description ) ) $description = $blog_name . "-" . trim( wp_title('', false) );
9 d3 a4 q; y; ~ - } elseif ( is_home () ) { $description = $blog_name . "-" . get_bloginfo('description') . dopt('d_description'); // 首頁要自己加9 P$ N! w, E; i& R/ [8 u: R7 g
- } elseif ( is_tag() ) { $description = $blog_name . "'" . single_tag_title('', false) . "'";
' Q* b* r7 a! [" s3 Z1 @* a7 k) s - } elseif ( is_category() ) { $description = single_cat_title('', false) . "'";0 x* h2 l) {2 G
- } elseif ( is_archive() ) { $description = $blog_name . "'" . trim( wp_title('', false) ) . "'";
8 b! n4 X( \; t2 I - } elseif ( is_search() ) { $description = $blog_name . ": '" . esc_html( $s, 1 ) . "' 的搜索結果";; S' M& b" w" W7 k2 c% b! P" D' V
- } else { $description = $blog_name . "'" . trim( wp_title('', false) ) . "'";' p8 [; x) a6 D4 Y
- }$ Y- o& Y m5 \, p: p# n
- $description = mb_substr( $description, 0, 220, 'utf-8' ) . '..';. e5 l% B. ^3 z, f! L7 m
- echo "<meta name="description" content="$description" />\n";- B+ t R' a; m$ w, l1 |3 H
- }
複製代碼 . n6 D2 U2 L- Q
|