【发布时间】:2015-02-16 17:32:53
【问题描述】:
我想根据用户输入的 url 在我的 404 页面上包含自动搜索结果输出。
问题在于,在通常的 search.php 文件中,wordpress 从 URL 参数中获取值并使用常规循环,如下所示:
<?php while (have_posts()) : the_post(); ?>
<h1>Search Results</h1>
<a href="<?php the_permalink() ?>"> <h2><?php the_title(); ?></h2> </a>
<?php endwhile; ?>
如何获取它以便我可以在代码中手动输入搜索词?
非常感谢。
【问题讨论】:
-
您是否尝试使用
the_query_search? codex.wordpress.org/Function_Reference/the_search_query -
你能给我你的url结构吗?
标签: php wordpress loops search