Cum declari WooCommerce support pentru o tema WordPress

In acest articol o sa invatam cum se declara suportul WooCommerce pentru o tema WordPress. Practic prin aceste coduri puse in tema ia devine combatibila cu pluginul W00Commerce si se poate folosi tema pentru un magazin online. Atunci cand o tema nou activata in panoul de administrare daca nu este compatibila atunci o sa apara un mesajul ca acesta:

woo

Primul pas este sa duplicam page.php al temei si sal redenumim din page.php in woocommerce.php. Urmatorul pas este sa editam woocommerce.php, trebuie sa gasim the loop (vezi the loop) care de obicei incepe cu

if ( have_posts() ) :  si se termina cu <?php endif; ?> aceste coduri si tot ce este in ele trebuiesc sterse si inlocuite cu

<?php woocommerce_content(); ?>

Hooks in functions.php

Urmatoarele coduri o sa le introduceti in functions.php pentru compatibilitatea temei. Prima data unhook the WooCommerce wrappers.

remove_action( ‘woocommerce_before_main_content’, ‘woocommerce_output_content_wrapper’, 10); remove_action( ‘woocommerce_after_main_content’, ‘woocommerce_output_content_wrapper_end’, 10);

dupa care se introduc urmatoarele coduri:

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 ‘<section id=”main”>’; } function my_theme_wrapper_end() { echo ‘</section>’; }

WooCommerce support.

Aceste coduri la fel adaugate in functions.php

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

Descarca codurile din articol. Veti gasi un fisier woocommerce.php plus codurile din articol woo.txt

  woo.zip (665 downloads)

Lasă un răspuns

Adresa ta de email nu va fi publicată. Câmpurile obligatorii sunt marcate cu *

Alte articole Populare