2010-09-17 76 views
1

我的search.php文件提及到的函數調用:WordPress的搜索 - Get_Template_Part

<?php 
    /* Run the loop for the search to output the results. 
    * If you want to overload this in a child theme then include a file 
    * called loop-search.php and that will be used instead. 
    */ 
     get_template_part('loop', 'search'); 
    ?> 

所有似乎很好地工作帶回我的搜索結果,但我也想顯示我的側邊欄和頁腳部分但是這個get_template_part似乎覆蓋了它。

任何想法如何在search.php文件結果頁中仍然顯示我的側欄和頁腳信息?

它似乎有它自己的div部分,因爲我的側邊欄顯示在結果集的上方或下方。

謝謝。

回答

-2

使用自定義WP查詢(檢索特定陣列中只給出頁)與此類似:

<?php 
$args=array(
    'post_type'=>'page', 
    'post__in' => array('595', '33', 44) 
); 
$the_query = new WP_Query($args); 
?> 

欲瞭解更多信息來建立它特定於您的需求,請參閱:http://codex.wordpress.org/Function_Reference/WP_Query

+0

嗨@Todd,不知道該如何這涉及到我的查詢用在我的search.php中的文件裏面,我也希望這個頁面來顯示我的兩個側邊欄和頁腳信息使用get_sidebar並與結果一起get_footer搜索過程。目前,我似乎無法同時使用側邊欄和get_template_part()。謝謝。 – tonyf 2010-09-18 00:02:27