我正在開發一個wordpress,其中包含一個用於顯示新聞的主頁和帖子頁面。在wordpress中創建一個不同的index.php
據我所知,Post Page使用的模板是index.php,但index.php也被其他頁面使用。
事情是,我想創建一個特殊頁面的帖子,頭部說新聞等,但我不希望其他網頁使用該模板。 有沒有辦法創建一個僅用於顯示帖子的替代index.php(index_news.php)?
這樣我可以使用index_news.php作爲post和index.php的其他所有內容。
感謝
編輯//////////
我的第一選擇是創建內部環路一個新的頁面模板(news.php),然後,在wordpress選項,將帖子定位到新的頁面(news.php)。
但是,當我這樣做,它加載index.php而不是news.php模板。也許這個循環出了問題。下面是我使用的循環:
<!-- Start the Loop. -->
<div class="post">
<!-- Display the Title as a link to the Post's permalink. -->
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
<!-- Display the Post's content in a div box. -->
<div class="entry">
<?php the_content(); ?>
</div>
<!-- Display a comma separated list of the Post's Categories. -->
<p class="postmetadata">Posted in <?php the_category(', '); ?></p>
</div> <!-- closes the first div box -->
<!-- Stop The Loop (but note the "else:" - see next line). -->
<?php endwhile; else: ?>
<!-- The very first "if" tested to see if there were any Posts to -->
<!-- display. This "else" part tells what do if there weren't any. -->
<p>Sorry, no posts matched your criteria.</p>
<!-- REALLY stop The Loop. -->
你可能想看看這個[Wordpress模板層次概述](http://codex.wordpress.org/Template_Hierarchy)。 – 2013-02-08 14:40:16