【问题标题】:Wordpress: Display multiple static pages on one page (Single Page website)Wordpress:在一页上显示多个静态页面(单页网站)
【发布时间】:2014-01-29 17:17:04
【问题描述】:

将单页网站转变为 wordpress 网站的最佳做法是什么?我应该如何在一个文件(例如front-page.php)中呈现不同的页面,一个接一个地出现? 页面上的每个部分都应该是不同的 wordpress(静态)页面。一个模板渲染其他模板?

提前谢谢你!

【问题讨论】:

    标签: wordpress-theming wordpress


    【解决方案1】:

    在 index.php 文件中使每个部分成为页面名称的后查询。

    <section>
    <?php query_posts('pagename=youpagename'); if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <div>the coontent etc.</div>
    <?php endwhile; ?>
    </section>
    

    【讨论】:

      【解决方案2】:

      这是我不久前使用的一些代码。或许能帮到你。 确保在测试时与后端的 ID 匹配页面。

      <section id="usp" class="clearfix">
      
          <?php
      
              $pages = get_pages('include=11,212,15,17&sort_column=menu_order');
      
              $count = 0;
      
              foreach($pages as $page)
      
              {
      
              $content = $page->post_excerpt;
      
          ?>
      
          <div class="column">
      
              <div class="inner">
      
                  <h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
      
                  <div class="usp-excerpt"><p><?php echo $content ?></p></div>
      
                  <a href="<?php echo get_page_link($page->ID) ?>" title="<?php echo $page->post_title ?>" class="usp-readmore">More&hellip;</a>
      
              </div> <!-- end inner -->
      
          </div> <!-- end column -->
      
          <?php } ?>
      
      </section> <!-- end usp -->
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-12-12
        • 1970-01-01
        • 2014-09-10
        • 2019-09-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多