你可以钓到the_permalink 过滤并检查is_search() 有条件地修改搜索结果的URL,以包含您的single.php 然后检查。类似的内容(可能需要修补):
add_filter( \'the_permalink\', \'wpse155331_the_permalink\' );
function wpse155331_the_permalink( $url ) {
if ( is_search() ) {
$url = add_query_arg( array( \'from_search\' => \'true\' ), $url );
}
return $url;
}