搜索页可以使用户快速找到自己想要的内容,可以提高用户浏览体验,是网站常用的扩展功能之一,搜索页一般主要有,搜索关键词与搜索结果列表组成
1、wordpress搜索词调用
<? echo get_search_query()?>
2、wordpress搜索结果列表调用
方法一 直接使用分类列表页循环方式即可
方法二
<?
if(have_posts()){
while(have_posts() ){
the_post();
?>
<li>
<div class="shijian">
<?php the_time('y-m') ?>
<span><?php the_time('d') ?></span>
</div> <a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php the_title();?></a>
<p><? the_excerpt(); ?></p>
<p></p>
</li>
<? }
}else{
echo "没有搜索到文章";
}
?>