2017-02-19 61 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