【问题标题】:WordPress Search - Get_Template_PartWordPress 搜索 - Get_Template_Part
【发布时间】:2010-09-17 16:12:54
【问题描述】:

我的 search.php 文件引用了以下函数调用:

    <?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 部分,因为我的侧边栏要么出现在结果集的上方或下方。

谢谢。

【问题讨论】:

    标签: wordpress wordpress-theming


    【解决方案1】:

    我不知道您的问题是否得到解决。但只是为了提供信息,可以创建一个搜索页面模板。此法典页面中提供了详细信息。

    http://codex.wordpress.org/Creating_a_Search_Page#Using_the_page.php

    【讨论】:

      【解决方案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

      【讨论】:

      • 嗨@Todd,不确定这与我的search.php文件中的查询有何关系,我还希望此页面使用get_sidebar和get_footer显示我的侧边栏和页脚信息以及来自的结果搜索过程。目前,我似乎无法让侧边栏和 get_template_part() 一起工作。谢谢。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-28
      • 2011-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多