2016-07-16 54 views
0

我在wordpress一個初學者,我嘗試了所有的辦法,但我不能讓我的主題woocommerce支持的。下面是我的page.php文件woocommerce支持不工作

page.php文件

<?php 
/** 
* The template for displaying pages 
* 
* This is the template that displays all pages by default. 
* Please note that this is the WordPress construct of pages and that 
* other "pages" on your WordPress site will use a different template. 
* 
*/ 
?> 
<?php get_header(); ?> 
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> 
     <div class="page"> 
      <?php if (have_posts()) : ?> 
      <?php while(have_posts()) : the_post(); ?> 

       <div class="post"> 
        <h3 class="<?php post_class(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3> 
        <div class="entry-content"> 
         <?php the_content(); ?> 
        </div> 
        <?php 
         // If comments are open or we have at least one comment, load up the comment template. 
         if (comments_open() || get_comments_number()) { 
          comments_template(); 
         } 
        ?> 
       </div> 

      <?php endwhile; ?> 
      <?php endif; ?> 
     </div> 
    </div> 

<?php get_footer(); ?> 

起初我重複page.php創造woocommerce.php,並上傳到服務器,但失敗了,下面是我的woocommerce.php

woocommerce.php

<?php 
/** 
* The template for displaying pages 
* 
* This is the template that displays all pages by default. 
* Please note that this is the WordPress construct of pages and that 
* other "pages" on your WordPress site will use a different template. 
* 
*/ 
?> 


<?php get_header(); ?> 
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> 
     <div class="page"> 
      <?php woocommerce_content(); ?> 
     </div> 
    </div> 
<?php get_footer(); ?> 

但它失敗了,在此之後,我從服務器上刪除woocommerce.php和編輯我functions.php文件添加woocommerce支持的代碼。以下是我在我的functions.php文件中添加的代碼。

remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); 
remove_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); 

add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10); 
add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10); 

function my_theme_wrapper_start() { 
    echo '<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"><div class="page">'; 
} 

function my_theme_wrapper_end() { 
    echo '</div></div>'; 
} 

add_action('after_setup_theme', 'woocommerce_support'); 
function woocommerce_support() { 
    add_theme_support('woocommerce'); 
} 

但它也失敗了,你可以看到輸出here

如果您在調試器看你看,沒有woocommerce css文件已加載。

請幫我同意你的建議。謝謝。

+0

檢查以下鏈接以將woocommerce集成到自定義主題中:https://docs.woothemes.com/document/template-structure/ –

+0

將您的woocommerce文件複製到主題目錄中,然後創建文件woocomerce.php並粘貼page.php文件代碼到woocommerce.php文件 –

+0

@hardiksolanki我查了一下,但還是同樣的 –

回答

0

去在初始化函數最優選的functions.php,在頂部添加此,

add_theme_support('woocommerce'); 

+0

謝謝,這是我尋找的那種。 – Stan

+0

謝謝,你可以投票答覆 –