2016-07-16 5 views
0

私はwordpressの初心者です。私はすべての方法を試しましたが、テーマをwoocommerceにすることはできません。以下は、以下の私のwoocommerce.phpワードプレスのテーマのwoocommerceサポートは動作しません

で、私は page.phpを複製し、 woocommerce.phpを作成し、サーバーにアップロード最初は私のpage.php

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(); ?> 

ですが、それは失敗します

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'); 
} 

が、それはまた失敗し、あなたがデバッガに表示されている場合は、あなたが何woocommerce CSSファイルがロードされていないことを確認することができ、出力here

を見ることができます。

ご意見をお寄せください。ありがとうございました。

+0

カスタムテーマでwoocommerceを統合するためのこのリンクを確認してください:https://docs.woothemes.com/document/template-structure/ –

+0

woocommerceファイルをテーマディレクトリにコピーしてから、woocomerce.phpファイルを作成して貼り付けてくださいpage.phpコードをwoocommerce.phpファイル –

+0

@hardiksolanki私はチェックしましたが、まだ同じです –

答えて

0

は、初期化機能で、最も好ましくは、

add_theme_support('woocommerce'); 

をのfunctions.phpとトップでこれを追加して行きます。

+0

ありがとう、これは私が探していたanwerでした。 – Stan

+0

ありがとうございます、あなたは答えを投票することができます –

関連する問題