سلام
این رو تست کنید
add_action('template_redirect', 'redirect_products_to_category');
function redirect_products_to_category() {
// Define the category slug you want to redirect
$category_slug = 'your-category-slug';
// Check if you are on a single product page
if (is_product()) {
global $post;
// Get the product's categories
$product_categories = wp_get_post_terms($post->ID, 'product_cat');
foreach ($product_categories as $category) {
if ($category->slug === $category_slug) {
// Redirect to