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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵