drdu53813 2017-02-19 20:21
浏览 47
已采纳

PHP WordPress的'the_content'问题[重复]

This question already has an answer here:

I probably have an easy issue here: I'm new to php and WordPress template development: in my php I get error 'Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF)'

I basically created a page and added content there and want to display dynamically on my home page.

Code below:

 <?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 error is somewhere in the the_content(); if statement. But not sure whats wrong tried going over the documentation: https://developer.wordpress.org/reference/functions/the_content/

Any tip is appreciated as I'm new to this.

</div>
  • 写回答

1条回答 默认 最新

  • douchun3680 2017-02-19 20:29
    关注

    You opened an if statement but you didn't close it at:

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

    Just close it after closing the while loop:

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

    This should solve your problem. Take a look at: http://php.net/manual/en/control-structures.alternative-syntax.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?