我在某处读到*)有一些q
wp\\u查询对象内部的一部分,用于识别搜索引擎访问者并显示他们搜索的关键字。
我目前正在开发local,因此无法访问/查看$GLOBALS[\'wp_query\']->q;
.
如果存在此问题和/或有其他检索解决方案,是否有人可以更改:
搜索引擎名称在引擎内搜索的搜索字符串*)记不清在哪里,但这与“更好的搜索结果页面”有关;“高亮显示搜索词”。
--EDIT --
到目前为止,我得到的是:
// declare the server itself as invalid to only catch search engine results
$http_referer = explode( "/", $_SERVER[\'HTTP_REFERER\'] );
$http_referer = $http_referer[2];
$home_url = explode( "/", home_url() );
$home_url = $home_url[2];
// Coming from a search engine: modify to a search string
if ( isset( $_SERVER[\'HTTP_REFERER\'] ) && $home_url !== $http_referer )
{
// remove previous "s" search query args
remove_query_arg( \'s\' );
$string = parse_url( $_SERVER[\'HTTP_REFERER\'] );
$query = $string[\'query\'];
$query = explode( "&", $query );
foreach ( $query as $q )
{
$q = urldecode( $q );
$arr = explode( "=", $q );
if ( (string) \'q\' === $arr[0] )
$search_string = $arr[1];
}
// build a new "s" search query arg: if isset, from the string entered in the search engines input form
// in theory that should allow treating it like a normal search result
// the draw back is, that a search engine visitor would never get directly to a post or page
if ( isset( $search_string ) )
add_query_arg( array( \'s\' => $search_string ) );
}
除了没有搜索引擎访问者会直接得出结果这一缺点之外,我不会以这种方式捕获所有搜索引擎。谷歌(Google)(&;Altavista获得
q=searchstring
查询参数。Yahoo for例如使用
p=
...