woocommerce_mini_cart();
echo WC()->cart->get_cart_contents_count();
<?php
/**
* Template Name: Название шаблона
*/
add_action('init', 'do_rewrite');
function do_rewrite(){
add_rewrite_rule( '^avtori/([^/]*)/([^/]*)/?', 'srt=$matches[1]', 'top' );
add_filter( 'query_vars', function( $vars ){
$vars[] = 'srt';
return $vars;
} );
}
$my_var = get_query_var('srt');
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#projects" aria-controls="projects" role="tab" data-toggle="tab">Все проекты</a></li>
<?php
$args = array(
'taxonomy' => 'afisha_kat',
'hide_empty' => true,
);
$terms = get_terms( $args );
foreach ($terms as $term) { ?>
<li role="presentation"><a href="#<?php echo $term->slug;?>" aria-controls="<?php echo $term->slug;?>" role="tab" data-toggle="tab"><?php echo $term->name; ?></a></li>
<?php }?>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="projects">
<?php
$args = array(
'post_type' => 'afisha',
'posts_per_page' => 8,
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<a href="<?php the_permalink();?>">
<figure class="project-thumb">
<?php the_post_thumbnail()?>
</figure>
<p class="project-descr">
<?php the_title();?>
</p>
</a>
<?php endwhile; ?>
</div>
<?php
endif; wp_reset_postdata(); ?>
</div>
<?php
$args = array(
'taxonomy' => 'afisha_kat',
'hide_empty' => true,
);
$terms = get_terms( $args );
foreach ($terms as $term) { ?>
<div role="tabpanel" class="tab-pane" id="<?php echo $term->slug;?>">
<div class="projects-grid">
<ul class="project-tabs-items">
<?php
$args = array(
'post_type' => 'afisha',
'posts_per_page' => 3,
'tax_query' => array(
array(
'taxonomy' => 'afisha_kat',
'field' => 'slug',
'terms' => $term->slug,
)
)
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<li>
<a href="<?php the_permalink();?>">
<figure class="project-thumb">
<?php the_post_thumbnail('project-thumb')?>
</figure>
<p class="project-descr">
<?php the_title();?>
</p>
</a>
</li>
<?php endwhile; ?>
<?php
endif; wp_reset_postdata(); ?>
</ul>
</div>
</div>
<?php } ?>
</div>
<?php global $post;
$post_tags = get_the_tags($post->ID);
$tag_query = array();
$i=0;
foreach ($post_tags as $tag) {
$tag_query[i] = $tag->name;
$i++;
}
$args = array (
'post_type' => 'product',
'posts_per_page' => 5,
'tax_query' => array(
array(
'taxonomy' => 'product_tag',
'field' => 'name',
'terms' => $tag_query,
)
)
);
$products = new WP_Query($args);
if ( $products->have_posts() ) :
while ( $products->have_posts() ) : $products->the_post();
//здесь выводим продукты в нужной разметке
endwhile;
endif; wp_reset_postdata();
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
//Код внутри цикла
<?php endwhile; ?>
<?php endif; ?>
<?php if(get_field("zavarka")) { ?>
<div class= "sposob_varki">
<div class= "sposob_varki1"><h3><center>СПОСОБ ЗАВАРИВАНИЯ</center></h3></div>
<?php the_field("zavarka");?>
</div>
<?php } ?>
function register_my_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_my_menu' );
<?php wp_nav_menu(array(
'menu' => 'header-menu', //название меню
'container' => 'nav', //контейнер
'container_class' => 'top-menu', //класс
));?>
add_action('pre_get_posts','my_function');
function my_function($query){
if( $query->is_page(Здесь ID нужной страницы) && $query->is_main_query() && ! $query->is_admin()) {
//здесь переопределяем аргументы, для цикла, например тип поста
$query->set('post_type', 'post');
}
}
function woocommerce_variable_add_to_cart() {
global $product;
// Enqueue variation scripts
wp_enqueue_script( 'wc-add-to-cart-variation' );
// Get Available variations?
$get_variations = sizeof( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );
// Load the template
wc_get_template( 'single-product/add-to-cart/variable.php', array(
'available_variations' => $get_variations ? $product->get_available_variations() : false,
'attributes' => $product->get_variation_attributes(),
'selected_attributes' => $product->get_variation_default_attributes()
) );
<?php
/**
* woocommerce_single_product_summary hook.
*
* @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_rating - 10
* @hooked woocommerce_template_single_price - 10
* @hooked woocommerce_template_single_excerpt - 20
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
*/
do_action( 'woocommerce_single_product_summary' );
?>
if ( ! function_exists( 'woocommerce_template_single_price' ) ) {
/**
* Output the product price.
*
* @subpackage Product
*/
function woocommerce_template_single_price() {
wc_get_template( 'single-product/price.php' );
}
}
This template can be overridden by copying it to yourtheme/woocommerce/single-product/price.php.
get_post_meta();
$product->get_price();
$product->is_on_sale();
и т.д. полный список методов здесь add_action('pre_get_posts','mandrivets_authors');
function mandrivets_authors($query){
if( $query->is_tax('authors') && $query->is_main_query() && ! $query->is_admin()) {
$query->set('wc_query', '');
$query->set('post_type', 'post');
$query->set('meta_query', '');
}
}
$terms = get_terms("my_taxonomy");
$count = count($terms);
if($count > 0){
echo "<ul>";
foreach ($terms as $term) {
echo '<li><a href="'.get_term_link($term).'">'.$term->name.'</a></li>';
}
echo "</ul>";
}