编程到搜索中

发布于 2024-12-18 12:59:35 字数 502 浏览 8 评论 0原文

这又是一个 WordPress 问题。提前致谢。
我的目标
1、请求网址:localhost/search_encoded_searh_words.html
2、mod重写为:localhost/search.php?s=encoded_search_words
3、search.php是我创建的文件,就像index.php一样,开头多了一行。 $_GET['s']=解码($_GET['s'])
问题
wordpress判断这是页面文件请求而不是搜索请求,标题显示找不到页面
简述
我想在解码搜索词后进行搜索
有解决办法吗?

我的技巧
search.php 中将 REQUEST_URI 修改为 localhost/?s=decoded_search_words

again this is a wordpress question.Thanks in advance.
My goal:
1,request url : localhost/search_encoded_searh_words.html
2,mod rewrite to:localhost/search.php?s=encoded_search_words
3,search.php is my create file,just like index.php with one more line at the beginning. $_GET['s']=decode($_GET['s'])
Problems
wordpress judge this is a page file request not search request,title shows Page not found
in brief
I want to search after decoding the search words
Any work around?

My trick:
in search.php modify the REQUEST_URI to localhost/?s=decoded_search_words

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

獨角戲 2024-12-25 12:59:36

尝试将 url 重写为 localhost/index.php?s=encoded_search_words
然后在 search.php 中,您需要从 $query_string 获取查询字符串,query_string 看起来像“s=search_key”,您需要解析它并解码它。然后使用 query_postcodex 更改查询结果是这样的

query_posts( $args );

// The Loop
while ( have_posts() ) : the_post();
    echo '<li>';
    the_title();
    echo '</li>';
endwhile;

// Reset Query
wp_reset_query();

try to rewrite the url to localhost/index.php?s=encoded_search_words,
then in search.php you need to get the query string from $query_string the query_string will looks something like "s=search_key", you need to parse it and decode it. then use query_postcodex to alter the query result like this.

query_posts( $args );

// The Loop
while ( have_posts() ) : the_post();
    echo '<li>';
    the_title();
    echo '</li>';
endwhile;

// Reset Query
wp_reset_query();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文