找到你要的答案

Q:Custom Wordpress search and query url

Q:自定义WordPress的搜索和查询网址

I try to create a custom search page in a Wordpress website. I read a few tutorials on Google and I have almost finished with it.

My theme uses the index.php page for the search results. So, I duplicated it, rename it to searchpage.php, made it a template and created a page with this template in Wordpress admin.

Then, I changed the action on the Search form to use the new page of /search.

If I manually try the /search/test/ it works. If I use the widget it redirect to /search/?s=test and returns a 404 page.

Is there any way to make both works or prevent the widget to use the second?

Also, the /search/test still uses the index.php layout instead of the searchpage.php

我试图在一个WordPress网站创建一个自定义的搜索页面。我读了一些谷歌教程,我几乎完成了它。

我的主题使用index.php页面的搜索结果。所以,我复制了它,将它重新命名为searchpage.php,做模板,创建了一个页面,这个模板在WordPress的管理。

然后,我改变了搜索窗体上的操作,使用新的搜索页。

如果我手动尝试/搜索/测试/ IT工程。如果我使用它重定向到/搜索/?测试并返回404页。

有没有办法使两个作品或防止小部件使用第二个?

另外,/搜索/测试仍然使用index.php布局相反的searchpage.php

answer1: 回答1:

In order to overwrite index.php as the default search results page you'll need to name your file search.php

为了覆盖index.php作为默认的搜索结果页,你将需要你的文件名称的search.php

php  wordpress