مخفی کردن تصویر شاخص در صفحه محصول ووکامرس

حذف تصویر شاخص

مخفی کردن تصویر شاخص در صفحه محصول ووکامرس – حذف تصویر شاخص در صفحه سینگل محصول برای همه محصولات.

تصویر شاخص در صفحه محصول ووکامرس

برای حذف تصاویر شاخص برای تمام محصولات، کد زیر را به فایل فایل functions.php اضافه کنید:

add_filter( 'mweb_woothumbs_all_image_ids', 'mweb_remove_featured_on_single', 10, 2 );

function mweb_remove_featured_on_single( $all_images, $id ) {
unset( $all_images['featured'] );
return $all_images;
}

حذف تصاویر شاخص در صفحه محصول تنها برای محصولاتِ با شناسه خاص
برای این منظور کد زیر را به فایل فایل functions.php اضافه کنید:


add_filter( 'mweb_woothumbs_all_image_ids', 'iconic_remove_featured_on_single', 10, 2 );

function mweb_remove_featured_on_single( $all_images, $id ) {

// Array of product IDs to remove the featured image from
$ids = array(12,24,25,32);

// if the current product is not in our above array,
// return the images as normal
if( !in_array($id, $ids) )
return $all_images;

// Otherwise, remove the featured image
unset( $all_images['featured'] );
return $all_images;

}

حذف تصویر شاخص در صفحه محصول تنها برای محصولاتِ در یک دسته خاص

برای این منظور کد زیر را به فایل فایل functions.php اضافه کنید:


add_filter( 'mweb_woothumbs_all_image_ids', 'mweb_remove_featured_on_single', 10, 2 );

function mweb_remove_featured_on_single( $all_images, $id ) {

// If our product is not in the "t-shirts" category,
// return the images as normal.
if( !has_term('t-shirts', 'product_cat', $id) )
return $all_images;

// otherwise, unset the featured image.
unset( $all_images['featured'] );
return $all_images;

}

حذف تصویر شاخص

امیدوارم این ایده خوبی باشه برای اینکه تصویر شاخص هر محصول خود را بر اساس شرایط خاصی حذف کنید.

امیدواریم از خواندن این مقاله لذت برده باشید.

نظرات خود را با ما به اشتراک بگذارید.

منتظر مقالات بیشتر در ماهدیس وب باشید.

ارسال دیدگاه

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

کد امنیتی Time limit is exhausted. Please reload CAPTCHA.