{"id":4313,"date":"2021-01-15T16:35:24","date_gmt":"2021-01-15T08:35:24","guid":{"rendered":"https:\/\/www.baishitou.cn\/?p=4313"},"modified":"2021-01-15T16:36:03","modified_gmt":"2021-01-15T08:36:03","slug":"wordpress%e7%ab%99%e5%86%85%e6%90%9c%e7%b4%a2%e6%9b%b4%e6%94%b9%e4%b8%ba%e7%99%be%e5%ba%a6%e6%90%9c%e7%b4%a2","status":"publish","type":"post","link":"https:\/\/www.baishitou.cn\/4313.html","title":{"rendered":"wordpress\u7ad9\u5185\u641c\u7d22\u66f4\u6539\u4e3a\u767e\u5ea6\u641c\u7d22"},"content":{"rendered":"

wordpress\u7ad9\u5185\u641c\u7d22\u66f4\u6539\u4e3a\u767e\u5ea6\u641c\u7d22\u7684\u65b9\u6cd5\u6bd4\u8f83\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4e0b\u5217\u4ee3\u7801\u5373\u53ef\uff0c\u6253\u5f00\u5f53\u524d\u4e3b\u9898\u4e0b\u7684functions.php\u52a0\u5165\u4e0b\u9762\u4ee3\u7801\u3002<\/p>\n

\/\/wordpress\u7ad9\u5185\u641c\u7d22\u66ff\u6362\u4e3a\u767e\u5ea6\u641c\u7d22\r\nfunction wp_use_baidu_search( $wp_query ) {\r\n  $s = '';  \r\n  if (isset($wp_query->query_vars['s'])) {\r\n    $s = trim($wp_query->query_vars['s']);\r\n  }\r\n  if (!$s) {  \/\/ \u7a7a\u641c\u7d22 \u4e0d\u8fdb\u884c\u8df3\u8f6c\r\n    return;\r\n  }\r\n  \/\/ \u83b7\u53d6\u5f53\u524d\u7f51\u7ad9\u57df\u540d\r\n  $host = strtolower($_SERVER['HTTP_HOST']);  \r\n  \/\/ \u4f7f\u7528 baidu \r\n  $search_engine = 'https:\/\/www.baidu.com\/s?ie=UTF-8&wd=';\r\n  $query = urlencode($s . ' site:' . $host);\r\n  \/\/ \u8fdb\u884c\u8df3 \u8f6c\r\n  wp_redirect($search_engine . $query);  \r\n  \/\/ \u4e0d\u518d\u7ee7\u7eed\r\n  exit;\r\n} \r\n\/\/ \u52a0\u5165 \u66ff\u6362\u5904\u7406\r\nadd_action('parse_query', 'wp_use_baidu_search');<\/code><\/pre>\n

\u6700\u7ec8\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n

\"\"<\/a><\/p>\n

\u5982\u679c\u641c\u7d22\u4e2d\u6587\u65f6\uff0c\u7ed3\u679c\u663e\u793a\u4e71\u7801\uff0c\u4e5f\u5c31\u662f\u88ab\u8f6c\u4e49\u4e86\uff0c<\/p>\n

\"\"<\/a><\/p>\n

 <\/p>\n

\u6253\u5f00search\u76f8\u5173\u4ee3\u7801\uff0c\u4e00\u822c\u5728header.php\u8fd9\u4e2a\u6587\u4ef6\u91cc\u9762\uff0c\u628a<\/p>\n

<?php echo home_url('\/search\/<\/span>'); ?><\/pre>\n

\u4fee\u6539\u4e3a\uff1a<\/p>\n

<?php echo home_url('\/?s=<\/span>'); ?><\/code><\/pre>\n

\u4fdd\u5b58\uff0c\u8fd9\u6837\u5c31\u80fd\u6b63\u5e38\u641c\u7d22\u4e2d\u6587\u4e86\u3002\u4eb2\u6d4b\u6709\u6548\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

wordpress\u7ad9\u5185\u641c\u7d22\u66f4\u6539\u4e3a\u767e\u5ea6\u641c\u7d22\u7684\u65b9\u6cd5\u6bd4\u8f83\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4e0b\u5217\u4ee3\u7801\u5373\u53ef\uff0c\u6253\u5f00\u5f53\u524d\u4e3b\u9898\u4e0b\u7684functions […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,1373,1372],"class_list":["post-4313","post","type-post","status-publish","format-standard","hentry","category-wljs","tag-wordpress","tag-1373","tag-1372"],"_links":{"self":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/4313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/comments?post=4313"}],"version-history":[{"count":0,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/4313\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/media?parent=4313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/categories?post=4313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/tags?post=4313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}