2014-09-29 26 views
0

我遇到了一些問題。我的page.php似乎重寫了WooCommerce的購物車頁面。該頁面已被創建(由WooCommerce生成,短代碼完好),名爲Cart。Woocommerce的購物車頁面被我的Page.php頁面覆蓋在Wordpress中

我知道我的page.php文件被覆蓋了,但我不知道如何停止。這裏是我的page.php文件頁面的代碼:

<?php 
get_header(); 

if (have_posts()) { 

    //Work with us page 
    $workwithuspage = "work with us"; 
    $pitch = "pitch an idea"; 
    $cart = "cart"; 

    if($workwithuspage == strtolower(get_the_title())) 
    { 
     //Page stuff here! 
     $image = wpse_get_images(); 
     ?> 
     </div> 
     <div class="hero"> 
      <div class="container heroImage" style="background-image:url('<?php echo $image->guid;?>');"> 
       <div class="col-md-7"></div> 
       <div class="col-md-5"> 
        <div class="pageText"> 
         Work with Us 
        </div> 
        <div class="subText"> 
         <?php echo $image->post_content; ?> 
        </div> 
       </div> 
      </div> 
     </div> 
     <div class="bodyBg"> 
      <div class="container"> 
       <div class="col-md-6"> 
        <div class="box-style"> 
         <div class="box-header"> 
          Got a comic idea and want it published? 
         </div> 
         <div class="box-text"> 
          Tell us your desires, so we can slap it on a comic book and sell it for millions. Ya dig? 
         </div> 
         <div class="box-button-container"> 
          <?php 
           $pitch = get_page_by_title('pitch an idea'); 
          ?> 
          <a href="<?php echo get_permalink($pitch); ?>"><div class="button large">Pitch an Idea</div></a> 
         </div> 
        </div> 
       </div> 
       <div class="col-md-6"> 
        <div class="box-style"> 
         <div class="box-header"> 
          Want to work on one of our great titles? 
         </div> 
         <div class="box-text"> 
          Tell us your desires, so we can slap it on a comic book and sell it for millions. Ya dig? 
         </div> 
         <div class="box-button-container"> 
          <div class="button large">Find Jobs</div> 
         </div> 
        </div> 
       </div> 
      </div> 
     </div> 
     <div id="ourstandards"> 
      <div class="coloroverlay"> 
       <div class="container"> 
        <div class="col-md-6"> 
         <div class="pageHeaderText"> 
          Our Standards 
         </div> 
         <div class="bodyTxt"> 
          <p> 
           At On Target Network, we strive to promote consistency, 
           communication and passion in all areas of work and we expect the same of our artists. 
          </p> 
          <p> 
           We understand the nature of creators and seek to raise ourselves to higher and higher standards. To do that, we vet and 
           review series pitches with a carefully selected panel of writers and artists. 
          </p> 
          <br /><br /> 
          <p> 
           Got questions? We'll be happy to help. 
          </p> 
          <div id="sendUsQ" class="secondaryBtn"> 
           Send us your questions 
          </div> 
         </div> 
        </div> 
        <div class="col-md-6"></div> 
       </div> 
      </div> 
     </div> 
     <div class="container"> 
     <?php 
    } 
    else if($pitch == strtolower(get_the_title())) 
    { 
     ?> 
     </div> 
     <div id="pitchImg" class="hero"> 
      <div class="container"> 
       <div class="col-md-7"></div> 
       <div class="col-md-5"> 
        <div class="pageText"> 
         Pitch an Idea 
        </div> 
        <div class="subText"> 
         <?php echo $image->post_content; ?> 
        </div> 
       </div> 
      </div> 
     </div> 
     <div class="bodyBg"> 
      <div class="container"> 
       <div class="col-md-12"> 
        <div class="pageHeaderText dark"> 
         Start your pitch here 
        </div> 
       </div> 
       <div class="col-md-9"> 
        <?php 
         if (isset($si_contact_form)) { 
          echo $si_contact_form->si_contact_form_short_code(array('form' => '1')); 
         } 
        ?> 
       </div> 
      </div> 
     </div> 
     <?php 
    } 
} 
get_footer(); 
?> 

我有我想自定義頁面條件IFS,但我擔心在這樣做時,它已經覆蓋(在某種程度上)的車頁面。

回答

1

WooCommerce使用簡碼添加購物車;簡碼會顯示爲頁面內容的一部分。 WP使用the_content()函數來顯示特定頁面或帖子的內容。您已從您的頁面模板中刪除the_content(),因此購物車不顯示。

看你的頁面模板,你已刪除the_content()和直接內聯的所有內容到模板中,而不是從數據庫中獲取它。這是一個普遍的WP網站的典型例子,但我知道有時一個網站從靜態開始,而你只是想把它變成'WP'。

您還使用了一堆條件語句來顯示不同的內容塊,這是違背使用模板的想法。我的建議是爲您的「音調」和「與我們一起工作」頁面創建單獨的頁面模板,並使page.php只是一個默認頁面模板,其中包含the_content()。通過這種方式,您可以爲任何頁面使用通用模板,包括購物車頁面。

檢查上創建自定義頁面模板的詳細信息,但簡而言之,你添加註釋到文件的頂部:

<?php 
/* 
Template Name: My Custom Page 
*/ 

然後將文件保存在你的主題文件夾中。通常的做法是將其命名爲page-pitch.php,以便您可以輕鬆識別它。然後在管理區域中,您可以將模板分配到您想要的任何頁面,只需從下拉菜單中選擇它即可。

將不同的內容分割成單獨的模板有兩個好處;即您不再需要使用條件來檢查頁面標題(這可能因安裝而異),並使您更容易進行調試。

+0

你知道,我試圖做一個「其他」的聲明,看看購物車頁面將與'the_content工作()',但是,事實並非如此。 – Majo0od 2014-09-29 21:50:15

+0

我的意思是沒有,這是一個空白的頁面。 – Majo0od 2014-09-29 21:50:35

+0

另外,是否有創建不同頁面模板的最佳做法? – Majo0od 2014-09-29 21:52:13

相關問題