• 07-12-2024, 18:09:14
    #10
    https://drive.google.com/file/d/1hLk...ew?usp=sharing herkes kullanabilir dowsnload linkim
    Kullanımı
    temada index.php içinde görünmesini istediğiniz alana

    <?php echo do_shortcode('[turkiye_ajans_manset]');?>
    Veya bu kod veya bileşenler içinde metin belgesine [turkiye_ajans_manset] kodu ekliyorsunuz

    $category = 'turkiye-gundemi-haber'; // Varsayılan kategori adı burada istediğinişz ketegori ismini yazıyorsunuz

    'posts_per_page' => 9, burayada kaç adet çıkmasını istiyorsan o kadar rakam yazıyrsun

    Bu kadar
  • 07-12-2024, 18:13:18
    #11
    Full kod bu şekilde
    <?php
    /*
    Plugin Name: Türkiye Ajans Manset v1
    Description: A customizable news slider plugin pulling content from WordPress posts.
    Version: 1.1
    Author: Mustafa Çakar
    web:https://www.turkiyeajans.com
    */
    
    // Slider'ı oluşturan fonksiyon
    function custom_news_slider() {
        $category = 'turkiye-gundemi-haber'; // Varsayılan kategori adı
    
        // WP Query ile istenen kategoriden postları çek
        $args = array(
            'post_type'      => 'post',
            'posts_per_page' => 9,
            'category_name'  => $category,
        );
        $query = new WP_Query($args);
    
        // Rastgele pozisyonlar için dizi
        $positions = array('bottom-left', 'bottom-right', 'middle-left', 'middle-right', 'center');
    
        if ($query->have_posts()) :
            ob_start(); ?>
            
            <div class="custom-news-slider">
                <div class="slider-wrapper">
                    <?php 
                    $i = 1;
                    while ($query->have_posts()) : $query->the_post();
                        // Öne çıkan görsel
                        $image_url = get_the_post_thumbnail_url(get_the_ID(), 'full') ?: 'https://via.placeholder.com/800x480';
    
                        // Başlık için rastgele pozisyon seçimi
                        $random_position = $positions[array_rand($positions)];
                    ?>
                    <div class="main-slide slide-<?php echo $i; ?> <?php echo ($i == 1) ? 'active' : ''; ?>"> 
                        <a href="<?php the_permalink(); ?>">
                            <img src="<?php echo esc_url($image_url); ?>" alt="<?php the_title_attribute(); ?>">
                            <div class="slider-title <?php echo esc_attr($random_position); ?>"><?php the_title(); ?></div>
                        </a>
                    </div>
                    <?php $i++; endwhile; ?>
                </div>
    
                <!-- Sağ ve sol yön okları -->
                <div class="arrow arrow-left">❮</div>
                <div class="arrow arrow-right">❯</div>
            </div>
    
            <!-- Thumbnails kısmı (slider'ın altında) -->
            <div class="thumbnails">
                <?php 
                $i = 1;
                // Yeniden WP Query'yi çalıştırmak için başlangıçtan başla
                $query->rewind_posts();
                while ($query->have_posts()) : $query->the_post(); ?>
                <div class="thumbnail" data-slide="<?php echo $i; ?>"><?php echo $i; ?></div>
                <?php $i++; endwhile; ?>
            </div>
    
            <?php
            wp_reset_postdata(); 
            return ob_get_clean();
        else :
            return '<p>No posts found in this category.</p>';
        endif;
    }
    
    // Shortcode ekle
    add_shortcode('turkiye_ajans_manset', 'custom_news_slider');
    
    // CSS ve JS kodlarını inline olarak ekle
    function custom_news_slider_inline_scripts() {
        ?>
        <style>
            .custom-news-slider {
                width: 100%;
                width: 100%;
                margin: 0 auto;
                position: relative;
                overflow: hidden;
            }
    
            .slider-wrapper {
                position: relative;
                height: 480px;
            }
    
            .main-slide {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                display: none;
                opacity: 0;
                transition: opacity 0.5s ease;
            }
    
            .main-slide.active {
                display: block;
                opacity: 1;
            }
    
            .main-slide img {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }
    
            /* Başlık stilini düzenleme */
            .slider-title {
                position: absolute;
                color: white;
                padding: 10px;
                font-size: 25px;
                background-color: rgba(255, 0, 0, 0.7); /* Saydam kırmızı arka plan */
                border-radius: 5px;
                font-weight: bold;
                text-shadow: 2px 2px 5px rgba(128, 128, 128, 0.7); /* Gri gölge */
            }
    
            /* Farklı başlık konumları */
            .top-center { top: 10px; left: 50%; transform: translateX(-50%); }
            .bottom-center { bottom: 10px; left: 50%; transform: translateX(-50%); }
            .top-left { top: 10px; left: 10px; }
            .top-right { top: 10px; right: 10px; }
            .bottom-left { bottom: 10px; left: 10px; }
            .bottom-right { bottom: 10px; right: 10px; }
            .middle-left { top: 50%; left: 10px; transform: translateY(-50%); }
            .middle-right { top: 50%; right: 10px; transform: translateY(-50%); }
            .center { top: 50%; left: 50%; transform: translate(-50%, -50%); }
    
            /* Thumbnail stil ayarları */
            .thumbnails {
                display: flex;
                justify-content: center;
                margin-top: 10px;
                position: relative;
                flex-wrap: wrap; /* Thumbnail'ların birden fazla satıra yayılmasına izin verir */
            }
    
            .thumbnail {
                border: 2px solid red;
                background-color: transparent; /* Arka plan saydam */
                color: red; /* Yazı rengi kırmızı */
                display: flex;
                align-items: center;
                justify-content: center;
                margin: 0 5px; /* Boşluk ayarı */
                cursor: pointer;
                border-radius: 50%;
                font-weight: bold;
                transition: background-color 0.3s ease, color 0.3s ease;
                font-size: 1em; /* Font boyutu ayarı */
                width: 30px; /* Sabit genişlik */
                height: 30px; /* Sabit yükseklik */
                max-width: 30px; /* Maksimum genişlik */
                max-height: 30px; /* Maksimum yükseklik */
            }
    
            .thumbnail.active {
                background-color: red;
                color: white;
            }
    
            .thumbnail:hover {
                background-color: red;
                color: white; /* Rakam beyaz olmalı */
            }
    
            /* Yön okları */
            .arrow {
                position: absolute;
                top: 50%;
                width: 40px;
                height: 40px;
                background-color: rgba(0, 0, 0, 0.5);
                color: white;
                font-size: 20px;
                text-align: center;
                line-height: 40px;
                cursor: pointer;
                border-radius: 50%;
                transform: translateY(-50%);
            }
    
            .arrow-left { left: 10px; }
            .arrow-right { right: 10px; }
    
            .arrow:hover {
                background-color: rgba(0, 0, 0, 0.8);
            }
    
            /* Mobil cihazlar için okları gizle */
            @media (max-width: 768px) {
                .arrow { display: none; }
            }
    
            @media (max-width: 480px) {
                .custom-news-slider { max-width: 100%; }
                .slider-title { font-size: 18px; padding: 5px; }
                .thumbnail {
                    width: 25px; /* Mobilde biraz daha küçük */
                    height: 25px; /* Mobilde biraz daha küçük */
                }
            }
        </style>
    
        <script>
            jQuery(document).ready(function($) {
                var currentSlide = 1;
                var totalSlides = $('.main-slide').length;
    
                function showSlide(slideIndex) {
                    $('.main-slide').removeClass('active');
                    $('.slide-' + slideIndex).addClass('active');
                    currentSlide = slideIndex;
                }
    
                $('.thumbnail').on('mouseenter', function() {
                    var slideIndex = $(this).data('slide');
                    showSlide(slideIndex);
                });
    
                $('.arrow-left').on('click', function() {
                    currentSlide = (currentSlide - 1) < 1 ? totalSlides : currentSlide - 1;
                    showSlide(currentSlide);
                });
    
                $('.arrow-right').on('click', function() {
                    currentSlide = (currentSlide + 1) > totalSlides ? 1 : currentSlide + 1;
                    showSlide(currentSlide);
                });
    
                setInterval(function() {
                    currentSlide = (currentSlide + 1) > totalSlides ? 1 : currentSlide + 1;
                    showSlide(currentSlide);
                }, 5000); 
            });
        </script>
        <?php
    }
    add_action('wp_footer', 'custom_news_slider_inline_scripts');
  • 07-12-2024, 18:37:01
    #12
    mustafa76 adlı üyeden alıntı: mesajı görüntüle
    Full kod bu şekilde
    <?php
    /*
    Plugin Name: Türkiye Ajans Manset v1
    Description: A customizable news slider plugin pulling content from WordPress posts.
    Version: 1.1
    Author: Mustafa Çakar
    web:https://www.turkiyeajans.com
    */
    
    // Slider'ı oluşturan fonksiyon
    function custom_news_slider() {
        $category = 'turkiye-gundemi-haber'; // Varsayılan kategori adı
    
        // WP Query ile istenen kategoriden postları çek
        $args = array(
            'post_type'      => 'post',
            'posts_per_page' => 9,
            'category_name'  => $category,
        );
        $query = new WP_Query($args);
    
        // Rastgele pozisyonlar için dizi
        $positions = array('bottom-left', 'bottom-right', 'middle-left', 'middle-right', 'center');
    
        if ($query->have_posts()) :
            ob_start(); ?>
            
            <div class="custom-news-slider">
                <div class="slider-wrapper">
                    <?php
                    $i = 1;
                    while ($query->have_posts()) : $query->the_post();
                        // Öne çıkan görsel
                        $image_url = get_the_post_thumbnail_url(get_the_ID(), 'full') ?: 'https://via.placeholder.com/800x480';
    
                        // Başlık için rastgele pozisyon seçimi
                        $random_position = $positions[array_rand($positions)];
                    ?>
                    <div class="main-slide slide-<?php echo $i; ?> <?php echo ($i == 1) ? 'active' : ''; ?>">
                        <a href="<?php the_permalink(); ?>">
                            <img src="<?php echo esc_url($image_url); ?>" alt="<?php the_title_attribute(); ?>">
                            <div class="slider-title <?php echo esc_attr($random_position); ?>"><?php the_title(); ?></div>
                        </a>
                    </div>
                    <?php $i++; endwhile; ?>
                </div>
    
                <!-- Sağ ve sol yön okları -->
                <div class="arrow arrow-left">❮</div>
                <div class="arrow arrow-right">❯</div>
            </div>
    
            <!-- Thumbnails kısmı (slider'ın altında) -->
            <div class="thumbnails">
                <?php
                $i = 1;
                // Yeniden WP Query'yi çalıştırmak için başlangıçtan başla
                $query->rewind_posts();
                while ($query->have_posts()) : $query->the_post(); ?>
                <div class="thumbnail" data-slide="<?php echo $i; ?>"><?php echo $i; ?></div>
                <?php $i++; endwhile; ?>
            </div>
    
            <?php
            wp_reset_postdata();
            return ob_get_clean();
        else :
            return '<p>No posts found in this category.</p>';
        endif;
    }
    
    // Shortcode ekle
    add_shortcode('turkiye_ajans_manset', 'custom_news_slider');
    
    // CSS ve JS kodlarını inline olarak ekle
    function custom_news_slider_inline_scripts() {
        ?>
        <style>
            .custom-news-slider {
                width: 100%;
                width: 100%;
                margin: 0 auto;
                position: relative;
                overflow: hidden;
            }
    
            .slider-wrapper {
                position: relative;
                height: 480px;
            }
    
            .main-slide {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                display: none;
                opacity: 0;
                transition: opacity 0.5s ease;
            }
    
            .main-slide.active {
                display: block;
                opacity: 1;
            }
    
            .main-slide img {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }
    
            /* Başlık stilini düzenleme */
            .slider-title {
                position: absolute;
                color: white;
                padding: 10px;
                font-size: 25px;
                background-color: rgba(255, 0, 0, 0.7); /* Saydam kırmızı arka plan */
                border-radius: 5px;
                font-weight: bold;
                text-shadow: 2px 2px 5px rgba(128, 128, 128, 0.7); /* Gri gölge */
            }
    
            /* Farklı başlık konumları */
            .top-center { top: 10px; left: 50%; transform: translateX(-50%); }
            .bottom-center { bottom: 10px; left: 50%; transform: translateX(-50%); }
            .top-left { top: 10px; left: 10px; }
            .top-right { top: 10px; right: 10px; }
            .bottom-left { bottom: 10px; left: 10px; }
            .bottom-right { bottom: 10px; right: 10px; }
            .middle-left { top: 50%; left: 10px; transform: translateY(-50%); }
            .middle-right { top: 50%; right: 10px; transform: translateY(-50%); }
            .center { top: 50%; left: 50%; transform: translate(-50%, -50%); }
    
            /* Thumbnail stil ayarları */
            .thumbnails {
                display: flex;
                justify-content: center;
                margin-top: 10px;
                position: relative;
                flex-wrap: wrap; /* Thumbnail'ların birden fazla satıra yayılmasına izin verir */
            }
    
            .thumbnail {
                border: 2px solid red;
                background-color: transparent; /* Arka plan saydam */
                color: red; /* Yazı rengi kırmızı */
                display: flex;
                align-items: center;
                justify-content: center;
                margin: 0 5px; /* Boşluk ayarı */
                cursor: pointer;
                border-radius: 50%;
                font-weight: bold;
                transition: background-color 0.3s ease, color 0.3s ease;
                font-size: 1em; /* Font boyutu ayarı */
                width: 30px; /* Sabit genişlik */
                height: 30px; /* Sabit yükseklik */
                max-width: 30px; /* Maksimum genişlik */
                max-height: 30px; /* Maksimum yükseklik */
            }
    
            .thumbnail.active {
                background-color: red;
                color: white;
            }
    
            .thumbnail:hover {
                background-color: red;
                color: white; /* Rakam beyaz olmalı */
            }
    
            /* Yön okları */
            .arrow {
                position: absolute;
                top: 50%;
                width: 40px;
                height: 40px;
                background-color: rgba(0, 0, 0, 0.5);
                color: white;
                font-size: 20px;
                text-align: center;
                line-height: 40px;
                cursor: pointer;
                border-radius: 50%;
                transform: translateY(-50%);
            }
    
            .arrow-left { left: 10px; }
            .arrow-right { right: 10px; }
    
            .arrow:hover {
                background-color: rgba(0, 0, 0, 0.8);
            }
    
            /* Mobil cihazlar için okları gizle */
            @media (max-width: 768px) {
                .arrow { display: none; }
            }
    
            @media (max-width: 480px) {
                .custom-news-slider { max-width: 100%; }
                .slider-title { font-size: 18px; padding: 5px; }
                .thumbnail {
                    width: 25px; /* Mobilde biraz daha küçük */
                    height: 25px; /* Mobilde biraz daha küçük */
                }
            }
        </style>
    
        <script>
            jQuery(document).ready(function($) {
                var currentSlide = 1;
                var totalSlides = $('.main-slide').length;
    
                function showSlide(slideIndex) {
                    $('.main-slide').removeClass('active');
                    $('.slide-' + slideIndex).addClass('active');
                    currentSlide = slideIndex;
                }
    
                $('.thumbnail').on('mouseenter', function() {
                    var slideIndex = $(this).data('slide');
                    showSlide(slideIndex);
                });
    
                $('.arrow-left').on('click', function() {
                    currentSlide = (currentSlide - 1) < 1 ? totalSlides : currentSlide - 1;
                    showSlide(currentSlide);
                });
    
                $('.arrow-right').on('click', function() {
                    currentSlide = (currentSlide + 1) > totalSlides ? 1 : currentSlide + 1;
                    showSlide(currentSlide);
                });
    
                setInterval(function() {
                    currentSlide = (currentSlide + 1) > totalSlides ? 1 : currentSlide + 1;
                    showSlide(currentSlide);
                }, 5000);
            });
        </script>
        <?php
    }
    add_action('wp_footer', 'custom_news_slider_inline_scripts');
    teşekkür ederim ilginiz için.
  • 07-12-2024, 19:03:50
    #13
    v3 yeni hazırladım istersen onu da paylaşabilirim bana whatsapp tan ulaşabilirsin