{"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