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

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

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型