编辑: 好吧,我不能用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