Edit File: pm9.php
<?php if (class_exists('CSF')) { CSF::createWidget('orun_widget_post_module_9', array( 'title' => esc_html__('Oruno - Kategori Modülü #2', 'orun'), 'class' => 'orun-widget-fields', 'classname' => 'orun-widget-post-module-9', 'description' => esc_html__('Kategorilerinizi görüntülemenizi sağlayan #2 numaralı modülümüz.', 'orun'), 'fields' => array( array( 'id' => 'title', 'type' => 'text', 'title' => esc_html__('Başlık:', 'orun'), 'subtitle' => esc_html__('Kategori modülünün başlığını girin.', 'orun'), 'help' => esc_html__('Kategori modülünün başlığını girin. Boş bırakırsanız modülün başlığı görünmez.', 'orun'), ), array( 'id' => 'postcount', 'type' => 'number', 'title' => esc_html__('Kategori Sayısı:', 'orun'), 'subtitle' => esc_html__('Kategori modülünde görüntülenecek kategori sayısını girin.', 'orun'), 'help' => esc_html__('Varsayılan: 5, modülde kaç tane kategori görüntüleneceği belirleyin.', 'orun'), 'default' => 6, ), array( 'id' => 'cat', 'type' => 'select', 'title' => esc_html__('Kategori:', 'orun'), 'subtitle' => esc_html__('Kategorilerin filtreleneceği kategori/kategorileri seçin.', 'orun'), 'placeholder' => esc_html__('Tüm Kategoriler', 'orun'), 'help' => esc_html__('Birden fazla kategori seçebilirsiniz. Hiç kategori seçmezseniz tüm kategoriler listelenecektir.', 'orun'), 'options' => 'categories', 'multiple' => true, 'chosen' => true, ), ) )); if (!function_exists('orun_widget_post_module_9')) { function orun_widget_post_module_9($args, $instance) { if (!empty($instance['title'])) { echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; } echo '<div class="orun-pm orun-pm-category-2">'; // Seçilen kategori/kategorilerin ID'lerini alın $selected_categories = !empty($instance['cat']) ? $instance['cat'] : array(); $args = array( 'orderby' => 'name', 'order' => 'ASC', 'include' => $selected_categories, ); $categories = get_categories($args); // Seçilen kategori sayısını alın $category_count = !empty($instance['postcount']) ? intval($instance['postcount']) : 6; // Kategorileri döngüye alın foreach ($categories as $category) { if ($category_count <= 0) { break; // Belirtilen sayıda kategori görüntülendiyse döngüyü durdur } $category_link = esc_url(get_category_link($category->term_id)); $category_name = $category->name; $category_post_count = $category->count; // Kategoriye ait yazı sayısı // Renkler ve stil $text_color = '#fff'; // Örnek yazı rengi $bg_color = '#000'; // Örnek arka plan rengi // Kategori arka plan resminin ID'sini al $category_background_image_id = get_term_meta($category->term_id, 'category_background_image', true); if (!empty($category_background_image_id)) { // Arka plan resmi varsa ID'yi kullanarak resim URL'sini al $category_background_image_url = wp_get_attachment_url($category_background_image_id); if ($category_background_image_url) { // Arka plan resmi varsa stil ve yazı rengini güncelle $bg_style = 'background: linear-gradient(to bottom, #00000085, #00000085), url(' . esc_url($category_background_image_url) . ') no-repeat center center / cover !important;'; $text_color = '#fff'; // Arka plan resmi olduğunda yazı rengini güncelle } } else { $bg_style = 'background-color: ' . $bg_color . ' !important;'; } ?> <div class="orun-pm-text"> <a style="color: <?php echo $text_color; ?> !important; <?php echo $bg_style; ?>" rel="nofollow" href="<?php echo $category_link; ?>" class="orun-pm-category"> <div class="orun-category-div"> <span class="orun-category-title"> <?php echo $category_name; ?> </span> </div> </a> </div> <?php $category_count--; // Kategori sayısını azalt } echo '</div>'; } } } ?>