【发布时间】:2016-02-11 09:47:30
【问题描述】:
在下面的代码中,我正在检查如果我在网站的主页上,那么我会将列向右移动 2,对于所有其他页面,我不应该有任何偏移.我正在尝试实现这一点,但出现错误。如果您能给我一个提示,那就太好了。谢谢!
<?php if (is_front_page() ) {
echo '<div class="col-md-8 la-content-inside col-md-offset-2">';
while ( have_posts() ) { the_post(); }
} else {
echo '<div class="col-md-8 la-content-inside">';
while ( have_posts() ) { the_post(); }
}
?>
<?php get_template_part( 'content', 'page' ); ?>
<?php endwhile; // end of the loop. ?>
</div>
【问题讨论】:
-
尝试将
while ( have_posts() ) : the_post();更改为while ( have_posts() ) { the_post(); }并请描述错误 -
我认为您正在使用三元 while 并没有结束。它应该像“while (have_posts()) : the_post(); endwhile;”
-
我的原始代码是:--->-------------- 我想让这部分代码只在其他页面而不是主页上工作。对于主页,我想要 2 的列偏移量
标签: php html wordpress if-statement echo