親,妳好,很高興為妳回答。
首先妳要準備2個文件
1個是在wordpress主題下的search.php文件
1個是檢索頁面需要放入html代碼。
<form action="/" method="get">
<input name="s" type="text" placeholder="網站檢索" id="s" value="<? the_search_query(); ?>" /> <input name="sa" value="檢索" type="image" src="<?php bloginfo('template_url'); ?>/images/search_icon.gif" align="top" class="btn" /> </form>上面這些是放在頁面的form表單
========================================================================
下面這些是放在search.php裏的代碼
<?php/**
*?The?template?for?displaying?all?pages. * *?This?is?the?template?that?displays?all?pages?by?default. *?Please?note?that?this?is?the?WordPress?construct?of?pages *?and?that?other?'pages'?on?your?WordPress?site?will?use?a *?different?template. * *?@package?Hotlink *?@subpackage?Hotlink?Theme *///?検索結果用?
$search_query?=&?new?WP_Query("s=$s?&?showposts=-1");
get_header();>
<section?class="main?clearfix">
<?php?if?(have_posts())?:?while?(have_posts())?:?the_post();>
<div?id="post-<?php?the_ID();>"?class="search_post">
<div?class="search_title">
<a?href="<?php?the_permalink();>"?title="<?php?the_title_attribute();>"?rel="bookmark">
<?php?the_title();>
<span?class="search_text"><?php?the_excerpt();></span>
</a></div>
<?php?the_date()>?<?php?the_time()>
</div>
<?php?endwhile;?else:>
<p?class="search_text">
<?php?_e('您要搜索的內容不存在');>
</p>
<?php?endif;>
<div?class="nav-previous">
<?php?previous_posts_link(__('«?Older?Entries',?'kubrick'));>
</div>
<div?class="nav-next">
<?php?next_posts_link(__('Newer?Entries?»',?'kubrick'));>
</div>
</section>
<?php?get_footer();>
如果可以使用,記得采納呦。。有問題繼續追問我。