网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

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

GG网络技术分享 2025-03-18 16:12 0


问题描述:

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>

图片转代码服务由CSDN问答提供

感谢您的意见,我们尽快改进~

功能建议

此问题已经存在 这里有一个答案:</ p>

  • PHP解析/语法错误; 以及如何解决它们?

    17 answers

    </ span>

    </ li>

    </ ul>

    </ div>

    我可能在这里有一个简单的问题:我是php和WordPress模板开发的新手:在我的php中我得到错误\'Parse 错误:语法错误,意外结束文件,期待elseif(T_ELSEIF)或否则(T_ELSE)或endif(T_ENDIF)\'</ p>

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

    下面的代码:</ p>

     &lt;?php 

    / **

    template name:Home Page

    * /

    \\ nget_header(); ?&gt;

    &lt;! - HERO - &gt;

    &lt; section id =“hero”&gt;

    &lt; article&gt;

    &lt; div class =“container-fluid clearfix “&gt;

    &lt;?php if(have_posts()):while(have_posts()):the_post(); ?&GT;

    &lt; div class =“col-lg-3”“hero-text”&gt;

    &lt; p class =“lead newfont”&gt;&lt;?php the_content(); ?&GT;&LT; / p为H.

    &lt; / div&gt;&lt;! - col - &gt;

    &lt;?php endwhile; ?&GT;

    &lt; / div&gt;&lt;! - 容器 - &gt;

    &lt; / article&gt;&lt;! - article - &gt;

    &lt; / section&gt;&lt;! - HERO - &gt;

    &lt;?php

    get_footer();

    </ code> </ pre>

    错误发生在the_content(); 如果声明。 但不确定是什么错误尝试审阅文档: https://developer.wordpress.org/ reference / functions / the_content / </ p>

    我很欣赏任何提示,因为我是新手。</ p>

    </ div>

    网友观点:

    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

标签:

提交需求或反馈

Demand feedback