<?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>";
}
<?php
/*
Template Name: archive
*/
?>
<?php get_header(); ?>
<div class="page-content-wrapper">
<div class="single-page-content">
<div class="breadcrumbs" typeof="BreadcrumbList" vocab="http://schema.org/">
<?php if(function_exists('bcn_display'))
{
bcn_display();
}?>
</div>
<div class="news-sidebar-row">
<?php wp_nav_menu( array( 'container_class' => 'news-menu', 'menu' => 'news' , 'menu_class' => 'news-nav' , 'theme_location' => 'primary' ) ); ?>
</div>
<article>
<div class="entry">
<?php if ( have_posts() ) : ?>
<?php
// Start the loop.
while ( have_posts() ) : the_post();?>
<div class="news-entry">
<?php the_post_thumbnail( 'thumbnail', array( 'class' => 'alignleft' ) ); ?>
<div class="news-title">
<p><?php the_date(); ?></p>
<h4><a href="<?php the_permalink(); ?>" title="Читати далі"><?php the_title(); ?></a></h4>
</div>
<div class="news-excerpt">
<?php echo(get_the_excerpt()); ?>
<div class="read-more-news"><a href="<?php the_permalink(); ?>" title="Читать дальше">Читать дальше</a></div>
</div>
</div>
<?php endwhile; ?>
</div>
</article>
<?php
the_posts_pagination( array(
'prev_text' => __( 'Previous page' ),
'next_text' => __( 'Next page' ),
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page' ) . ' </span>',
) ); ?>
<?php endif;
?>
</div>
</div>
<?php get_footer(); ?>
<?php get_header(); ?>
<?php
the_archive_title( '<h1 class="page-title">', '</h1>' );
/* Start the Loop */
while ( have_posts() ) : the_post();
the_title();
the_excerpt(); ?>
<a href="<?php the_permalink();?>">Читать далее ></a>
<?php
endwhile;
$pagination_args = array(
'prev_text' => __( '«' ),
'next_text' => __( '»' )
);
the_posts_pagination($pagination_args);
endif; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>