slider product woocommerce (ok)
PreviousYITH WooCommerce Wishlist với ['yith_wcwl_add_to_wishlist'] not working (ok)NextNotice: id was called incorrectly. Product attributes should not be accessed directly (ok)
Last updated
function woo_product_category($args = ['cateid' => 15,'colums'=>5])
{
$arg = [
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => '8',
'tax_query' => [
[
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $args['cateid'],
'operator' => 'IN',
],
[
'taxonomy' => 'product_visibility',
'field' => 'slug',
'terms' => 'exclude-from-catalog',
'operator' => 'NOT IN',
],
],
];
$query = new WP_Query($arg);
$wooproductcategory = '';
$wooproductcategory .= '<div uk-slider class="productcategory">';
$wooproductcategory .= '<div class="uk-position-relative">';
$wooproductcategory .= '<div class="uk-slider-container uk-light">';
$wooproductcategory .= '<ul class="uk-slider-items uk-child-width-1-2 uk-child-width-1-3@s uk-child-width-1-'.$args["colums"].'@m">';
if ($query->have_posts()) {
while ($query->have_posts()): $query->the_post();
global $product, $post;
$link = get_permalink($product->get_id());
$title = '<h2 class="titleh2"><a href="' . $link . '">' . get_the_title() . '</a></h2>';
$wooproductcategorys = get_the_post_thumbnail($post->ID, 'full');
$price = $product->get_price_html();
if (empty($wooproductcategorys)) {
$wooproductcategorys = '<img src="https://inop.vyanh.net/wp-content/uploads/2019/01/beanie-with-logo-1.jpg" alt="aaaaaaaaa" />';
}
$wooproductcategory .= '<li>';
$wooproductcategory .= '<a href="' . $link . '">' . $wooproductcategorys . '</a>';
$wooproductcategory .= '<div class="wrapcontentproduct uk-text-center">';
$wooproductcategory .= $title;
$wooproductcategory .= $price;
$wooproductcategory .= '</div>';
$wooproductcategory .= '</li>';
endwhile;
wp_reset_postdata();
}
$wooproductcategory .= '</ul>';
$wooproductcategory .= '</div>';
$wooproductcategory .= '<div class="uk-visible">';
$wooproductcategory .= '<a class="uk-position-center-left-out uk-position-small" href="#" uk-slidenav-previous uk-slider-item="previous"></a>';
$wooproductcategory .= '<a class="uk-position-center-right-out uk-position-small" href="#" uk-slidenav-next uk-slider-item="next"></a>';
$wooproductcategory .= '</div>';
$wooproductcategory .= '</div>';
$wooproductcategory .= '</div>';
return $wooproductcategory;
}
add_shortcode('wooproductcategory', 'woo_product_category');
[wooproductcategory cateid="15" colums="5"]