2013-08-27 53 views
0

我想修改一個基於wp基礎的兒童主題,我試圖編輯首頁。WordPress的主題刪除PHP的原因導致空白屏幕

這是主題中的首頁代碼;

<?php 
/* 
Template Name: Homepage 
*/ 
?> 

<?php get_header(); ?> 

      <div id="content"> 

       <div id="main" class="twelve columns" role="main"> 

        <article role="article"> 

         <?php 

         $orbit_slider = of_get_option('orbit_slider'); 
         if ($orbit_slider){ 

         ?> 

         <header> 

          <div id="featured"> 

          </div> 

         </header> 


         <?php } ?> 

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

         <section class="row post_content"> 

          <div class="home-main eight columns"> 

           <?php the_content(); ?> 

          </div> 


         </section> <!-- end article header --> 

         <footer> 

          <p class="clearfix"><?php the_tags('<span class="tags">Tags: ', ', ', '</span>'); ?></p> 

         </footer> <!-- end article footer --> 

        </article> <!-- end article --> 

        <?php 
         // No comments on homepage 
         //comments_template(); 
        ?> 

        <?php endwhile; ?> 



        </article> 

        <?php endif; ?> 

       </div> <!-- end #main --> 


      </div> <!-- end #content --> 

<?php get_footer(); ?> 

每當我試圖刪除一些代碼(我想擺脫內置的軌道滑塊,並使用例如插件),但是當我刪除了這片;

<?php 
$orbit_slider = of_get_option('orbit_slider'); 
         if ($orbit_slider){ 

         ?> 

該頁面只是空白。我以爲我以'乾淨'的方式來做這件事,儘管我對PHP並不熟悉,所以我不明白爲什麼頁面變得空白。我想刪除更多的PHP代碼(基本上我想要一個乾淨的空白頁面開始。)但他們都給出了相同的結果;一個空白頁。

爲什麼我不能刪除這些碎片,爲什麼會出現這種錯誤?

回答

1

可能您已刪除if ($orbit_slider){,但你已經離開了右大括號<?php } ?>

只是頭關閉標籤後刪除了這一行。

</header> 


     remove this ----> <?php } ?> 
1
您在wp-config.php文件找

define('WP_DEBUG', false);

define('WP_DEBUG', true);

,它會顯示錯誤,而不是黑屏(僅用於開發替代它) 對於這段代碼,你會得到錯誤,因爲

if ($orbit_slider){

啓動一個if循環。嘗試刪除唯一

$orbit_slider = of_get_option('orbit_slider');

+0

感謝您對調試的事情的意見,這是非常有用的!離開if循環導致了另一個錯誤。下面的答案(刪除結束標籤)解決了問題。 – Jane

+0

這肯定不會做,因爲如果循環仍在執行..如果($ orbit_slider)內部代碼的正確方法{ ?>

您必須刪除這整段代碼來避免設計問題 – codepixlabs