<?php
$page_id = get_option('page_on_front'); // или конкретный ID, например 123
if( have_rows('main-categories', $page_id) ): ?>
<section class="main-categories">
<ul class="main-category-list">
<?php while( have_rows('main-categories', $page_id) ) : the_row(); ?>
<li class="main-category-item">
<a href="<?php the_sub_field('main-category-url'); ?>">
<img src="<?php the_sub_field('main-category-img'); ?>" alt="<?php the_sub_field('main-category-title'); ?>" />
<h3><?php the_sub_field('main-category-title'); ?></h3>
</a>
</li>
<?php endwhile; ?>
</ul>
</section>
<?php endif; ?>
// Клик по оверлею — закрываем все модалки
if (overlay) {
overlay.addEventListener('click', function () {
for (let i = 0; i < modalparent.length; i++) {
modalparent[i].classList.remove('active');
}
html.classList.remove('sidebar-mobile-open');
overlay.classList.remove('active');
});
}
window.onclick = function(event) {
if (event.target === modalparent[event.target.getAttribute('data-index')]) {
modalparent[event.target.getAttribute('data-index')].classList.remove('active');
}
};
for (let i = 0; i < modalparent.length; i++) {
modalparent[i].addEventListener('click', function(e) {
if (!e.target.closest('.modal-content')) {
modalparent[i].classList.remove('active');
html.classList.remove('sidebar-mobile-open');
overlay.classList.remove('active');
}
});
}
add_action( 'woocommerce_before_shop_loop_item_title', 'maudern_remove_product_badges_wrapper', 5 );
function maudern_remove_product_badges_wrapper() {
remove_action( 'woocommerce_before_shop_loop_item_title', 'maudern_product_badges_wrapper_open', 5 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 6 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'maudern_product_badges_wrapper_close', 8 );
add_action( 'woocommerce_before_shop_loop_item_title', 'maudern_add_product_badges_wrapper', 5 );
}
function maudern_add_product_badges_wrapper() {
echo '<div class="wrap">';
maudern_product_badges_wrapper_open();
woocommerce_show_product_loop_sale_flash();
maudern_product_badges_wrapper_close();
echo '</div>';
}
<?php do_action( 'woocommerce_after_shop_loop_item' ); ?>
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
),
)
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="my-button"><?php do_action( 'woocommerce_after_shop_loop_item' ); ?></div>
<?php endwhile;
} else {
echo 'Товаров нет';
}
wp_reset_postdata(); ?>
<form class="clear-cart" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post"><button type="submit" onclick='javascript:if(!confirm("Удалить все товары из корзины?")) {return false;}' class="button" name="clear-cart">Очистить корзину</button></form>
add_action('init', 'woocommerce_clear_cart_url');
function woocommerce_clear_cart_url() {
global $woocommerce;
if( isset($_REQUEST['clear-cart']) ) {
$woocommerce->cart->empty_cart();
}
}
// предположим, header.php
// какое-то содержание
// ...
<?php
$acfFields = get_fields();
$metaDescriptionValue = $acfFields['about'] ? $acfFields['about'] : 'Meta Description по умолчанию';
?>
<meta name="description" content="<?= $metaDescriptionValue; ?>">
// ...
// остальное содержание