Shan Biswas
Shan Biswas

Reputation: 429

woocommerce support in wordpress theme not working

I am a beginner in wordpress and I tried all the ways but I cannot make my theme woocommerce supportable. Below is my 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(); ?>

At first I duplicate page.php and create woocommerce.php and upload to server, but it fails, below is my 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(); ?>

But it fails, after this I deleted woocommerce.php from server and edited my functions.php file to add woocommerce supportable code. Below is the code I added in my functions.php file.

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

but it also fails, you can see the output here

If you see in debugger you can see that no woocommerce css file has been loaded.

Please help me with your suggestion. Thank you.

Upvotes: 0

Views: 3600

Answers (1)

Biereagu Sochima
Biereagu Sochima

Reputation: 132

go to functions.php and add this at the top,

add_theme_support('woocommerce');

most preferably at an initialisation function.

Upvotes: 3

Related Questions