編輯: 好吧,我不能用is_page
條件處理它。所以我寫了下面的代碼 - 效果很好,但不是很好。有什麼建議麼?在循環內的單個頁面上獲得不同的頁面模板
<?php $args = array('post_type' => 'page');?> <!-- get only pages -->
<?php query_posts($args); ?>
<?php while (have_posts()) : the_post(); ?> <!-- loop with pages starts -->
<?php $id = get_the_ID(); ?> <!-- get post/pageID -->
<?php if ($id == 5) : include(get_stylesheet_directory() . '/page_special.php');
else: include(get_stylesheet_directory() . '/page_all.php');
endif;
?>
我試圖使用一個頁面佈局的wordpress主題。爲此 我編輯我的page.php文件到這一點,得到了不同的標題的頁面
<?php $args = array('post_type' => 'page'); ?> <?php query_posts($args); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <section id="<?php the_title(); ?>"> <header class="entry-header"> <h1 class="entry-title"><a name="<?php the_title(); ?>"></a> </h1> </header> <div class="entry-content"> <?php the_content(); ?> </div> </section> <?php endwhile; endif; ?>
的& 內容現在我想插入如果條件
is_page ('about') -> get_page_template ('about')
或類似的東西但WordPress的Codex說,在一個循環內
"is_page"
標籤不起作用。我不想將我所有的不同部分模板寫入一個,並且在同一個頁面模板中寫入 。當您在頁面上時,有沒有辦法調用不同的 頁面模板?
如果裏面...那麼......其他...... – 2013-05-04 19:31:24
好吧,thx丹尼斯。這正是我所期待的。 – mobsteady 2013-05-04 20:08:17