2017-02-19 87 views
0

我可能有一个简单的问题在这里:我是新来的PHP和WordPress模板开发:在我的PHP我得到错误'解析错误:语法错误,意外的文件结尾,期待elseif(T_ELSEIF )或其他(T_ELSE)或endif(T_ENDIF)'PHP WordPress的'the_content'问题

我基本上创建了一个页面,并在那里添加了内容,并希望在我的主页上动态显示。下面

代码:

<?php 
/** 
template name: Home Page 
*/ 

get_header(); ?> 

<!--HERO--> 
    <section id="hero"> 

     <article> 

      <div class="container-fluid clearfix"> 

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>     


        <div class="col-lg-3" "hero-text"> 
         <p class="lead newfont"><?php the_content(); ?></p> 
        </div><!--col--> 

<?php endwhile; ?>    

      </div><!--container--> 

     </article><!--article-->  

    </section><!--HERO--> 

<?php 

get_footer(); 

的错误是在the_content某处();如果声明。但不知道什么是错误的尝试通过文档:https://developer.wordpress.org/reference/functions/the_content/

任何提示是赞赏,因为我是新来的。

回答

1

if语句您打开了,但你没在关闭:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 

关闭while循环之后就关闭它:

<?php endwhile; ?> 
<?php endif; ?> 

这应该解决您的问题。看看:http://php.net/manual/en/control-structures.alternative-syntax.php

+0

感谢队友你真的在这里解决了这个菜鸟的错误,我还有一个问题,也许你知道答案:

<?php the_content(); ?>

'为什么the_content没有收到这个类“引导newfont”,就好像我将内容更改为标题,页面标题显示正确的方式。基本上会发生这种情况,会创建一个新的

元素,而不是像在代码中那样添加内容。 – Zygimantas

+0

这是一个CSS问题,而不是PHP。请发布一个提供示例代码的新问题 –

+0

无后顾之忧得到它的工作:remove_filter('the_content','wpautop'); remove_filter('the_excerpt','wpautop'); – Zygimantas