// Shortcode για εμφάνιση όλων των brands με αλφαβητική πλοήγηση add_shortcode('product_brands_alphabet', 'custom_product_brands_alphabet'); function custom_product_brands_alphabet($atts) { $atts = shortcode_atts(array( 'hide_empty' => 'false', 'orderby' => 'name', 'order' => 'ASC', 'columns' => 4, 'show_image' => 'true', 'show_name' => 'true', 'image_size' => 'medium', ), $atts); $args = array( 'taxonomy' => 'product_brand', 'hide_empty' => ($atts['hide_empty'] === 'true') ? true : false, 'orderby' => $atts['orderby'], 'order' => $atts['order'], ); $all_brands = get_terms($args); if (empty($all_brands) || is_wp_error($all_brands)) { return '

Δεν βρέθηκαν brands.

'; } // Ομαδοποίηση ανά πρώτο γράμμα $brands_by_letter = array(); foreach ($all_brands as $brand) { $first_letter = strtoupper(mb_substr($brand->name, 0, 1)); if (!isset($brands_by_letter[$first_letter])) { $brands_by_letter[$first_letter] = array(); } $brands_by_letter[$first_letter][] = $brand; } // Αλφαβητική ταξινόμηση των γραμμάτων ksort($brands_by_letter); // Ξεκινάμε output με CSS $output = ''; // Αλφαβητική πλοήγηση $output .= '
'; $output .= '
'; // Δημιουργία λίστας γραμμάτων A-Ω $greek_alphabet = array('Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ν', 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω'); $latin_alphabet = range('A', 'Z'); $all_letters = array_merge($greek_alphabet, $latin_alphabet); foreach ($all_letters as $letter) { $has_brands = isset($brands_by_letter[$letter]) && !empty($brands_by_letter[$letter]); $class = 'alphabet-letter'; $class .= $has_brands ? '' : ' empty'; $onclick = $has_brands ? ' onclick="document.getElementById(\'section-' . $letter . '\').scrollIntoView({behavior: \'smooth\'});"' : ''; $output .= '
' . $letter . '
'; } $output .= '
'; // Εμφάνιση brands ανά γράμμα foreach ($brands_by_letter as $letter => $brands) { $output .= '
'; $output .= '

' . $letter . '

'; $output .= '
'; foreach ($brands as $brand) { $brand_url = get_term_link($brand); $brand_image = get_term_meta($brand->term_id, 'thumbnail_id', true); $image_html = ''; if ($brand_image && $atts['show_image'] === 'true') { $image = wp_get_attachment_image_src($brand_image, $atts['image_size']); if ($image) { $image_html = '
' . esc_attr($brand->name) . '
'; } } $output .= ''; } $output .= '
'; $output .= '
'; } $output .= '
'; return $output; } φρέσκο πικάντικο | Sueño Aroma - αρωματοπωλείο
φρέσκο πικάντικο

Ξεκίνησε να πληκτρολογείς

Καλάθι Αγορών

Κανένα προϊόν στο καλάθι σας.