{"id":2001,"date":"2019-01-03T21:36:52","date_gmt":"2019-01-03T13:36:52","guid":{"rendered":"http:\/\/www.woniuseo.com\/?p=2001"},"modified":"2019-01-03T21:36:52","modified_gmt":"2019-01-03T13:36:52","slug":"wordpress%e5%a6%82%e4%bd%95%e4%b8%ba%e5%88%86%e7%b1%bb%e7%9b%ae%e5%bd%95%e6%b7%bb%e5%8a%a0%e5%85%b3%e9%94%ae%e8%af%8d%e5%92%8c%e9%95%bf%e6%a0%87%e9%a2%98%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/www.woniuseo.com\/2001.html","title":{"rendered":"wordpress\u5982\u4f55\u4e3a\u5206\u7c7b\u76ee\u5f55\u6dfb\u52a0\u5173\u952e\u8bcd\u548c\u957f\u6807\u9898\uff1f"},"content":{"rendered":"

\u6709\u65f6\uff0c\u505a\u7f51\u7ad9\u4f18\u5316\u65f6\uff0c\u5f88\u591a\u7ad9\u957f\u5e0c\u671bwordpress\u5206\u7c7b\u76ee\u5f55\u4e5f\u80fd\u6dfb\u52a0\u5173\u952e\u8bcd\u548c\u957f\u6807\u9898\u3002\u6211\u4eec\u90fd\u77e5\u9053\uff0cwordpress\u5728\u540e\u53f0\u6dfb\u52a0\u5206\u7c7b\u76ee\u5f55\u65f6\uff0c\u6ca1\u6709\u5173\u952e\u8bcd\u9009\u9879\uff0c\u4e5f\u6ca1\u6709\u957f\u6807\u9898\u9009\u9879\u3002\u53ea\u6709\u76ee\u5f55\u540d\u548c\u522b\u540d\u3001\u63cf\u8ff0\u3002\u5982\u679c\u53ea\u662f\u957f\u6807\u9898\uff0c\u8fd9\u4e2a\u8fd8\u597d\u89e3\u51b3\uff0c\u6211\u4eec\u53ea\u9700\u628a\u76ee\u5f55\u540d\u5199\u6210\u957f\u6807\u9898\uff0c\u7136\u540e\u5728\u540e\u53f0\u7684\u201c\u83dc\u5355\u201d\u91cc\u628a\u524d\u53f0\u7684\u5bfc\u822a\u83dc\u5355\u5199\u6210\u77ed\u6807\u9898\u5c31\u53ef\u4ee5 \u4e86\u3002\u4f46\u662f\u5173\u952e\u8bcd\u5c31\u6ca1\u6709\u529e\u6cd5\u4e86\uff0c\u6211\u4eec\u53ea\u80fd\u901a\u8fc7\u63d2\u4ef6\u6216\u4ee3\u7801\u6765\u5b9e\u73b0\u3002\u8fd9\u91cc\uff0c\u6211\u4eec\u5c31\u6765\u901a\u8fc7\u4ee3\u7801\u6765\u5b9e\u73b0\u5206\u7c7b\u76ee\u5f55\u7684\u957f\u6807\u9898\u548c\u5173\u952e\u8bcd\u529f\u80fd\u3002<\/p>\n

\u7b2c\u4e00\u6b65\u3001\u5728functions.php \u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n

\/\/\u5206\u7c7b\u76ee\u5f55 SEO \u4f18\u5316
\nadd_action(‘edit_category_form_fields’, ‘category_function’);
\nfunction category_function(){
\nif(isset($_GET[‘action’]) && $_GET[‘action’] == ‘edit’) $value = get_option(‘cat_set_’ . $_GET[‘tag_ID’]);
\n$title = ‘cat_title’;
\n$keywords = ‘cat_keywords’;
\n\/\/$description = ‘cat_description’;
\n?>
\n<table class=”form-table”>
\n<\/table>
\n<h2>\u81ea\u5b9a\u4e49SEO\u4fe1\u606f<\/h2>
\n<table class=”form-table”>
\n<tbody>
\n<tr class=”form-field”>
\n<th scope=”row” valign=”top”><label for=”<?php echo $title ?>”>\u6807\u9898<\/label><\/th>
\n<td>
\n<input name=”<?php echo $title ?>” id=”<?php echo $title ?>” type=”text” value=”<?php echo esc_attr(stripslashes($value[‘title’]));?>”>
\n<p class=”description”>\u9ed8\u8ba4\u8c03\u7528\u5206\u7c7b\u540d\u79f0\u4f5c\u4e3aHead\u4e2dTitle\u4fe1\u606f\u3002<\/p>
\n<\/td>
\n<\/tr>
\n<tr class=”form-field”>
\n<th scope=”row” valign=”top”><label for=”<?php echo $keywords; ?>”>\u5173\u952e\u8bcd<\/label><\/th>
\n<td>
\n<input name=”<?php echo $keywords; ?>” id=”<?php echo $keywords; ?>” type=”text” value=”<?php echo $value[‘keywords’];?>”>
\n<p class=”description”>\u591a\u4e2a\u5173\u952e\u8bcd\u7528\u5c0f\u5199\u9017\u53f7\u201c,\u201d\u5206\u9694\u5f00\uff1b\u9ed8\u8ba4\u8c03\u7528\u5206\u7c7b\u540d\u79f0\u4f5c\u4e3aHead\u4e2dKeyWords\u4fe1\u606f\u3002<\/p>
\n<\/td>
\n<\/tr>
\n<!–<tr class=”form-field”>
\n<th scope=”row” valign=”top”><label for=”<?php echo $description; ?>”>\u63cf\u8ff0<\/label><\/th>
\n<td>
\n<textarea name=”<?php echo $description; ?>” id=”<?php echo $description; ?>” rows=”3″ cols=”30″>
\n<?php echo stripslashes($value[‘description’]); ?>
\n<\/textarea>
\n<p class=”description”>\u82e5\u672a\u8bbe\u7f6e\uff0c\u5c06\u663e\u793a\u4e3a\u201c\u5173\u4e8e\u2018\u67d0\u67d0\u2019\u5206\u7c7b\u4e0b\u7684\u6240\u6709\u6587\u7ae0\u3002\u201d\u4f5c\u4e3aHead\u4e2dDescription\u4fe1\u606f\u3002<\/p>
\n<\/td>
\n<\/tr>–>
\n<\/tbody>
\n<\/table><\/p>\n

<?php
\n}
\nadd_action(‘edit_category’, ‘save_category_function’);
\nfunction save_category_function(){
\nif(isset($_POST[‘action’]) && isset($_POST[‘taxonomy’]) && $_POST[‘action’] == ‘editedtag’ && $_POST[‘taxonomy’] == ‘category’){
\nupdate_option(
\n‘cat_set_’ . $_POST[‘tag_ID’],
\narray(
\n‘title’ => $_POST[‘cat_title’],
\n\/\/’description’ => $_POST[‘cat_description’],
\n‘keywords’ => $_POST[‘cat_keywords’],
\n‘template’ => $_POST[‘cat_template’],
\n‘orderby’ => $_POST[‘cat_orderby’],
\n‘per_page’ => $_POST[‘cat_per_page’],
\n)
\n);
\n}
\n};<\/p><\/blockquote>\n

\u7b2c\u4e8c\u6b65\u3001\u8bbe\u7f6e\u4e0d\u540c\u9875\u9762\u663e\u793a\u4e0d\u540c\u7684\u6807\u9898\u3001\u5173\u952e\u8bcd\u3001\u63cf\u8ff0\uff0c\u628a\u4e0b\u9762\u4ee3\u7801\u653e\u5230 header-seo.php \u6587\u4ef6\u4e2d\uff1a<\/p>\n

<?php
\nif (is_home()){ \/\/\u9996\u9875SEO
\n$title =get_bloginfo(‘description’).” – “.get_bloginfo(‘name’);
\n$description = get_option(‘swt_description’);
\n$keywords = get_option(‘swt_keywords’);<\/p>\n

}elseif (is_category()){ \/\/\u5206\u7c7b\u76ee\u5f55SEO<\/p>\n

$cat_id = get_query_var(‘cat’);
\n$val = get_option(“cat_set_$cat_id”);
\n\/\/\u5206\u7c7b\u76ee\u5f55\u957f\u6807\u9898
\nif(!Empty($val) && $val[‘title’]!=”){
\n$title = $val[‘title’].’ – ‘.get_bloginfo(‘name’);
\n}else{
\n$title = single_cat_title(”, false).’ – ‘.get_bloginfo(‘name’);
\n}
\n\/\/\u5206\u7c7b\u76ee\u5f55\u5173\u952e\u8bcd
\nif(!Empty($val) && $val[‘keywords’]!=”){
\n$keywords = $val[‘keywords’];
\n}else{
\n$keywords = single_cat_title(”, false);
\n}
\n\/\/\u5206\u7c7b\u76ee\u5f55\u63cf\u8ff0
\n$description = category_description();<\/p>\n

}elseif (is_tag()){ \/\/\u6807\u7b7e\u9875<\/p>\n

$title = single_cat_title(”, false).’ – ‘.get_bloginfo(‘name’);
\n$description = tag_description();
\n$keywords = single_tag_title(”, false);<\/p>\n

}elseif (is_single()){ \/\/\u6587\u7ae0\u9875<\/p>\n

$title = $post->post_title.’ – ‘.get_bloginfo(‘name’);
\nif ($post->post_excerpt){
\n$description = $post->post_excerpt;
\n} else {
\n$description = substr(strip_tags($post->post_content),0,400);
\n}
\n$keywords = “”;
\n$tags = wp_get_post_tags($post->ID);
\nforeach ($tags as $tag ){
\n$keywords = $keywords . $tag->name . “, “;
\n}
\n}
\n?><\/p><\/blockquote>\n

\u7b2c\u4e09\u6b65\u3001\u5728header.php \u4e2d\u5f15\u7528\u6807\u9898\u3001\u5173\u952e\u3001\u63cf\u8ff0\uff1a<\/p>\n

<?php include “header-seo.php”; ?>
\n<title><?php echo $title; ?><\/title>
\n<meta name=”keywords” content=”<?php echo $keywords ?>” \/>
\n<meta name=”description” content=”<?php echo strip_tags($description); ?>” \/><\/p><\/blockquote>\n

\u901a\u8fc7\u8fd9\u4e09\u6b65\uff0c\u6211\u4eec\u5c31\u4e3awordpress\u5206\u7c7b\u76ee\u5f55\u6dfb\u52a0\u4e86\u957f\u6807\u9898\u548c\u5173\u952e\u8bcd\u529f\u80fd\u3002<\/p>\n

 <\/p>\n

\u4ee5\u4e0a\u5185\u5bb9\u6765\u81ea\u6765\u81ea\u7f51\u7edc\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6709\u65f6\uff0c\u505a\u7f51\u7ad9\u4f18\u5316\u65f6\uff0c\u5f88\u591a\u7ad9\u957f\u5e0c\u671bwordpress\u5206\u7c7b\u76ee\u5f55\u4e5f\u80fd\u6dfb\u52a0\u5173\u952e\u8bcd\u548c\u957f\u6807\u9898\u3002\u6211\u4eec\u90fd\u77e5\u9053\uff0cwordpress\u5728\u540e\u53f0\u6dfb\u52a0\u5206\u7c7b\u76ee\u5f55\u65f6\uff0c\u6ca1\u6709\u5173\u952e\u8bcd\u9009\u9879\uff0c\u4e5f\u6ca1\u6709\u957f\u6807\u9898\u9009\u9879\u3002\u53ea\u6709\u76ee\u5f55\u540d\u548c\u522b\u540d\u3001\u63cf\u8ff0\u3002\u5982\u679c\u53ea\u662f\u957f\u6807\u9898\uff0c\u8fd9\u4e2a\u8fd8\u597d\u89e3\u51b3\uff0c\u6211\u4eec\u53ea\u9700\u628a\u76ee\u5f55\u540d\u5199\u6210\u957f\u6807\u9898\uff0c<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.woniuseo.com\/wp-json\/wp\/v2\/posts\/2001"}],"collection":[{"href":"http:\/\/www.woniuseo.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.woniuseo.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.woniuseo.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.woniuseo.com\/wp-json\/wp\/v2\/comments?post=2001"}],"version-history":[{"count":1,"href":"http:\/\/www.woniuseo.com\/wp-json\/wp\/v2\/posts\/2001\/revisions"}],"predecessor-version":[{"id":2002,"href":"http:\/\/www.woniuseo.com\/wp-json\/wp\/v2\/posts\/2001\/revisions\/2002"}],"wp:attachment":[{"href":"http:\/\/www.woniuseo.com\/wp-json\/wp\/v2\/media?parent=2001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.woniuseo.com\/wp-json\/wp\/v2\/categories?post=2001"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.woniuseo.com\/wp-json\/wp\/v2\/tags?post=2001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}