<a href='javascript:;' id="alhpa">1234</a>
document.getElementById('alhpa').onclick = function(e){
if (document.selection) {
const range = document.body.createTextRange();
range.moveToElementText(this);
range.select();
} else if (window.getSelection) {
const range = document.createRange();
range.selectNode(this);
window.getSelection().addRange(range);
}
document.execCommand('copy');
return false;
}
// hide header on scroll down show on scroll up
const scroll = document.getElementById("site-header");
const scrollUp = "scroll-up";
const scrollDown = "scroll-down";
let lastScroll = 0;
window.addEventListener("scroll", () => {
const currentScroll = window.pageYOffset;
if (currentScroll <= 0) {
scroll.classList.remove(scrollUp);
return;
}
if (currentScroll > lastScroll && !scroll.classList.contains(scrollDown)) {
// down
scroll.classList.remove(scrollUp);
scroll.classList.add(scrollDown);
} else if (
currentScroll < lastScroll &&
scroll.classList.contains(scrollDown)
) {
// up
scroll.classList.remove(scrollDown);
scroll.classList.add(scrollUp);
}
lastScroll = currentScroll;
});
var ACTIVE = 'active';
$(".main-navigation > ul > li").on('click', function() {
let clickedElementIsActive = $(this).hasClass(ACTIVE);
$(".main-navigation > ul > li").removeClass(ACTIVE);
clickedElementIsActive ? $(this).removeClass(ACTIVE): $(this).addClass(ACTIVE);
});
<?php
$parentid = get_queried_object_id();
$args = array(
'parent' => $parentid,
'hide_empty' => false
);
$terms = get_terms( 'product_cat', $args );
if ( $terms ) {
echo '<div class="subcat-product"><ul class="subcat-product__content">';
foreach ( $terms as $term ) {
$thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true );
echo '<li class="subcat-product__item">';
//woocommerce_subcategory_thumbnail( $term );
echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . ' catalog-list-block__title">';
echo '<img style="background-image: url('. wp_get_attachment_url( $thumbnail_id ) .')!important;background-size: 100%;background-repeat: no-repeat;background-size: cover; width: 100px; height: 100px;" />';
echo $term->name;
echo '</a>';
echo '</li>';
}
echo '</ul></div>';
}
?>
add_theme_support(
'woocommerce',
array(
'thumbnail_image_width' => 150,
'single_image_width' => 300,
'product_grid' => array(
'default_rows' => 3,
'min_rows' => 1,
'default_columns' => 4,
'min_columns' => 1,
'max_columns' => 6,
),
)
);