• 02-02-2024, 03:20:36
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Aşağıda yer alan kodlarda otomatik olarak tüm basın ilan verileri geliyor after before kullanarak, ayrıca başlangıç ve bitiş tarihi seçildiğinde de ayıklayıp o tarih aralığına göre listeliyor. Benim yapamadığım uykusuz kalarak çözemediğim sorun aşağıdaki koda ne eklersem veya neyi değiştirirsem o günün tarihine ait sayfa açılır açılmaz veri gelebilir. Mesela o gün basın ilan veri yoksa gelmesi sadece tarih aralıkları seçildiğinde getiriyor zaten.

    <?php include(TEMPLATEPATH . '/thewp/headerilan.php'); ?>

    <?php
    global $wpdb;
    $tarih1 = isset($_GET['1tarih']) ? $_GET['1tarih'] : '';
    $tarih2 = isset($_GET['2tarih']) ? $_GET['2tarih'] : '';
    ?>

    <section class="top40">
    <div class="ortala">

    <div class="ilanFiltrele">
    <form method="get">
    <input name="1tarih" type="text" id="1tarih" placeholder="Tarih Seçiniz" <?php if($tarih1) echo 'value="'.$tarih1.'"'; ?> required>
    <input name="2tarih" type="text" id="2tarih" placeholder="Tarih Seçiniz" <?php if($tarih2) echo 'value="'.$tarih2.'"'; ?> required>
    <button name="ilanBul" id="ilanBul" type="submit" name="gonder" >Listele</button>
    </form>
    </div>

    <div class="kategoriilanlar2">

    <?php
    $current_page = get_query_var('paged');
    $current_page = max( 1, $current_page );
    $per_page = get_option( 'posts_per_page' );
    $offset_start = 0;
    $offset = ( $current_page - 1 ) * $per_page + $offset_start;
    $tema_ayarlar = get_option( 'yonetim_paneli' );
    $ilan_cat = $tema_ayarlar['basinilanKatSec'];

    $args = array(
    'offset'=>$offset,
    'posts_per_page'=> $per_page ,
    'paged' => $current_page,
    'cat' => array($ilan_cat),
    'date_query' => array(
    array(

    'after' => $tarih1,
    'before' => $tarih2.' 23:59',
    'inclusive' => true,
    ),
    ),
    );

    $the_query = new WP_Query( $args);
    $total_rows = max( 0, $the_query->found_posts - $offset_start );
    $total_pages = ceil( $total_rows / $per_page );
    if ( $the_query->have_posts() ) : $s=0;
    while ( $the_query->have_posts() ) : $the_query->the_post(); $s++;
    ?>

    <div class="liste">
    <a target="_blank" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    <figure>
    <?php if (has_post_thumbnail()) {
    vt_resize(get_post_thumbnail_id(), 365, 205, true);
    } else {
    echo '<img src="'.get_bloginfo('template_url').'/images/resmiilan.png" width="365" height="205"/>';
    } ?>
    </figure>
    <time><?php the_time('d F Y'); ?> - <?php the_time('G:i'); ?></time>
    <figcaption><?php the_title(); ?></figcaption>
    </a>
    </div>

    <?php endwhile; ?>
    <?php wp_reset_postdata(); ?>
    <?php else : ?>
    <div class="ilanbulunmadi">
    <strong>Seçtiğiniz tarihte uygun ilan bulunamadı!</strong>
    <p>Farklı bir tarih aralığı seçerek yeni arama yapabilirsiniz.</p>
    </div>
    <?php endif; ?>

    </div>

    <div class="temizle"></div>
    <?php theWPsayfala($total_pages,$current_page); ?>

    </div>
    </section>
    <div class="temizle"></div>

    <style>
    .ilanbulunmadi {
    position: relative;
    padding: 30px 15px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
    text-align: center;
    }
    .ilanbulunmadi strong {
    font-size: 20px;
    }
    .ilanbulunmadi p {
    font-size: 15px;
    margin-top: 5px;
    }

    .ilanFiltrele {
    width: calc(100% - 0px);
    height: auto;
    overflow: hidden;
    display: block;
    padding: 0px 0px;
    position: relative;
    z-index: 9;
    text-align: right;
    margin-bottom: 15px;
    }
    .ilanFiltrele input[type=text] {
    width: calc(102px - 2px);
    height: 44px;
    line-height: 44px;
    padding: 0px 15px;
    margin: 0px 3px 0px 0px;
    border: 1px solid #dedede;
    -webkit-transition: 0.5s;
    transition: 0.5s;
    outline: none;
    font-size: 14px;
    font-weight: 300;
    color: #747474;
    display: inline-table;
    }
    .ilanFiltrele input[type=text]:focus {
    border: 1px solid #dedede;
    box-shadow: 0px;
    }
    .ilanFiltrele button#ilanBul {
    width: auto;
    height: 44px;
    line-height: 44px;
    overflow: hidden;
    display: inline-table;
    background-color: #585858;
    cursor: pointer;
    color: rgba(0, 0, 0, 0);
    text-shadow: 0 0 0 #ffffff, 0 3rem 0 #ffffff;
    transition: background-color 150ms, text-shadow 200ms;
    font-size: 16px;
    font-weight: 500;
    border: 0px;
    outline: none;
    padding: 0px 30px;
    margin-left: 2px;
    }
    .ilanFiltrele button#ilanBul:hover {
    background-color: #d73516;
    text-shadow: 0 -3rem 0 #ffffff, 0 0 0 #ffffff;
    }
    .datepicker input {
    font-family: 'Roboto', sans-serif;
    display:block;
    border: none;
    border-radius: 0.25rem;
    border: 1px solid transparent;
    line-height: 1.5rem;
    padding: 0;
    font-size: 1rem;
    color: #607D8B;
    width: 100%;
    margin-top: 0.5rem;
    }
    .datepicker input:focus {
    outline: none;
    }
    #ui-datepicker-div {
    display: none;
    background-color: #fff;
    box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.2);
    margin-top: 0.25rem;
    padding: 0.5rem;
    z-index: 9999!important;
    }
    .datepicker table {
    border-collapse: collapse;
    border-spacing: 0;
    }
    .ui-datepicker-calendar thead th {
    padding: 0.25rem 0;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 400;
    color: #78909C;
    }
    .ui-datepicker-calendar tbody td {
    width: 2.5rem;
    text-align: center;
    padding: 0;
    }
    .ui-datepicker-calendar tbody td a {
    display: block;
    line-height: 2rem;
    transition: 0.3s all;
    color: #666;
    font-size: 0.875rem;
    text-decoration: none;
    }
    .ui-datepicker-calendar tbody td a:hover {
    background-color: #666;
    color: #ffffff;
    }
    .ui-datepicker-calendar tbody td a.ui-state-active {
    background-color: #d73516;
    color: white;
    }
    .ui-datepicker-header a.ui-corner-all {
    cursor: pointer;
    position: absolute;
    top: 0;
    width: 2rem;
    height: 2rem;
    margin: 0.5rem;
    border-radius: 0.25rem;
    transition: 0.3s all;
    }
    .ui-datepicker-header a.ui-corner-all:hover {
    background-color: #ECEFF1;
    }
    .ui-datepicker-header a.ui-datepicker-prev {
    left: 0;
    background: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5 vcmcvMjAwMC9zdmciIHdpZHRoPSIxMyIgaGVpZ2h0PSIxMyIgd mlld0JveD0iMCAwIDEzIDEzIj48cGF0aCBmaWxsPSIjNDI0Nzc wIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03LjI4OCA2LjI5N kwzLjIwMiAyLjIxYS43MS43MSAwIDAgMSAuMDA3LS45OTljLjI 4LS4yOC43MjUtLjI4Ljk5OS0uMDA3TDguODAzIDUuOGEuNjk1L jY5NSAwIDAgMSAuMjAyLjQ5Ni42OTUuNjk1IDAgMCAxLS4yMDI uNDk3bC00LjU5NSA0LjU5NWEuNzA0LjcwNCAwIDAgMS0xLS4wM DcuNzEuNzEgMCAwIDEtLjAwNi0uOTk5bDQuMDg2LTQuMDg2eiI vPjwvc3ZnPg==");
    background-repeat: no-repeat;
    background-size: 10px;
    background-position: 50%;
    transform: rotate(180deg);
    }
    .ui-datepicker-header a.ui-datepicker-next {
    right: 0;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5 vcmcvMjAwMC9zdmciIHdpZHRoPSIxMyIgaGVpZ2h0PSIxMyIgd mlld0JveD0iMCAwIDEzIDEzIj48cGF0aCBmaWxsPSIjNDI0Nzc wIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03LjI4OCA2LjI5N kwzLjIwMiAyLjIxYS43MS43MSAwIDAgMSAuMDA3LS45OTljLjI 4LS4yOC43MjUtLjI4Ljk5OS0uMDA3TDguODAzIDUuOGEuNjk1L jY5NSAwIDAgMSAuMjAyLjQ5Ni42OTUuNjk1IDAgMCAxLS4yMDI uNDk3bC00LjU5NSA0LjU5NWEuNzA0LjcwNCAwIDAgMS0xLS4wM DcuNzEuNzEgMCAwIDEtLjAwNi0uOTk5bDQuMDg2LTQuMDg2eiI vPjwvc3ZnPg==');
    background-repeat: no-repeat;
    background-size: 10px;
    background-position: 50%;
    }
    .ui-datepicker-header a>span {
    display: none;
    }
    .ui-datepicker-title {
    text-align: center;
    line-height: 2rem;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding-bottom: 0.25rem;
    color: #78909C;
    }
    .ui-datepicker-week-col {
    color: #78909C;
    font-weight: 400;
    font-size: 0.75rem;
    }
    </style>
    <script>
    $( function() {
    $( "#1tarih" ).datepicker();
    } );
    $( function() {
    $( "#2tarih" ).datepicker();
    } );
    $( function() {
    $( "#1tarih2" ).datepicker();
    } );
    $( function() {
    $( "#2tarih2" ).datepicker();
    } );
    </script>

    <?php include(TEMPLATEPATH . '/footer.php'); ?>
  • Kabul Edilen Cevap
    • 2 Beğeni
       array(
      'post_type'=> 'post',
      'orderby' => 'ID',
      'post_status' => 'publish',
      'order' => 'DESC',
      'posts_per_page' => 4,
      'cat' => $kategori,
      );
      Bu kısmı alttaki kod ile değişin

       array(
      'post_type'=> 'post',
      'orderby' => 'ID',
      'post_status' => 'publish',
      'posts_per_page' => 4,
      'cat' => $kategori,
      'date_query'    => array(
              array(
                  'after'     =>  date('Y-m-d'),
                  'before'    => date('Y-m-d') . ' 23:59',
                  'inclusive' => true,
              ),
          ),
      
      );
  • 02-02-2024, 03:27:47
    #2
    $args = array(
    'offset'=>$offset,
    'posts_per_page'=> $per_page ,
    'paged' => $current_page,
    'cat' => array($ilan_cat),
    'date_query' => array(
    array(
    
    'after' => $tarih1,
    'before' => $tarih2.' 23:59',
    'inclusive' => true,
    ),
    ),
    );
    Burayı alttaki kod ile değişin.
    $args = array(
        'offset'        => $offset,
        'posts_per_page'=> $per_page,
        'paged'         => $current_page,
        'cat'           => array($ilan_cat),
        'date_query'    => array(
            array(
                'after'     => ! empty($tarih1) ? $tarih1 : date('Y-m-d'),
                'before'    => ! empty($tarih2) ? $tarih2 . ' 23:59' : date('Y-m-d') . ' 23:59',
                'inclusive' => true,
            ),
        ),
    );
  • 02-02-2024, 03:31:37
    #3
    harew1 adlı üyeden alıntı: mesajı görüntüle
    $args = array(
    'offset'=>$offset,
    'posts_per_page'=> $per_page ,
    'paged' => $current_page,
    'cat' => array($ilan_cat),
    'date_query' => array(
    array(
    
    'after' => $tarih1,
    'before' => $tarih2.' 23:59',
    'inclusive' => true,
    ),
    ),
    );
    Burayı alttaki kod ile değişin.
    $args = array(
        'offset'        => $offset,
        'posts_per_page'=> $per_page,
        'paged'         => $current_page,
        'cat'           => array($ilan_cat),
        'date_query'    => array(
            array(
                'after'     => ! empty($tarih1) ? $tarih1 : date('Y-m-d'),
                'before'    => ! empty($tarih2) ? $tarih2 . ' 23:59' : date('Y-m-d') . ' 23:59',
                'inclusive' => true,
            ),
        ),
    );
    Allah razı olsun çalıştı. Fakat örneğin güncel ilan girildiğinde ilanı listeler değilmi o güne ait. Ertesi günü ilan yoksa güncel listelemez doğru değil mi
  • 02-02-2024, 03:38:53
    #4
    Hocam son bir sorum olacak ana sayfada da listelenen var burda sadece mevcut güne ait listelensin nasıl yapabiliriz. Son bir sorunum kaldı

    <section class="top40">
    <div class="ortala">

    <?php
    $kategori = $tema_ayarlar['basinilanKatSec'];$args = array(
    'post_type'=> 'post',
    'orderby' => 'ID',
    'post_status' => 'publish',
    'order' => 'DESC',
    'posts_per_page' => 4,
    'cat' => $kategori
    );
    $category = get_category($kategori);
    $kategori_adi = $category->cat_name;
    $kategori_url = get_category_link($kategori);
    ?>

    <div class="anaBaslik">
    <h2><?php echo $kategori_adi ?></h2>
    <div data-control="<?php echo $kategori_adi ?>"></div>
    <a target="_blank" href="<?php echo $kategori_url ?>" title="<?php echo $kategori_adi ?>"><?php echo $kategori_adi ?> <i class="fa-solid fa-arrow-right-from-bracket"></i></a>
    </div>

    <div id="resmiilan">

    <?php
    $result = new WP_Query( $args );
    if ( $result-> have_posts() ) : ?>
    <?php while ( $result->have_posts() ) : $result->the_post(); ?>
    <div class="resmiilan">

    <a target="_blank" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    <figure>
    <?php if (has_post_thumbnail()) {
    vt_resize(get_post_thumbnail_id(), 270, 153, true);
    } else {
    echo '<img src="'.get_bloginfo('template_url').'/images/resmiilan.png" width="270" height="153"/>';
    } ?>
    </figure>
    <time><?php the_time('d F Y'); ?> - <?php the_time('G:i'); ?></time>
    <figcaption><?php the_title(); ?></figcaption>
    </a>

    </div>
    <?php endwhile; ?>
    <?php endif; wp_reset_postdata(); ?>

    </div>

    </div>
    </section>
    <div class="temizle"></div>
  • 02-02-2024, 03:46:50
    #5
    Bu cevap, konu sahibi tarafından kabul edilebilir bir cevap olarak işaretlendi.
     array(
    'post_type'=> 'post',
    'orderby' => 'ID',
    'post_status' => 'publish',
    'order' => 'DESC',
    'posts_per_page' => 4,
    'cat' => $kategori,
    );
    Bu kısmı alttaki kod ile değişin

     array(
    'post_type'=> 'post',
    'orderby' => 'ID',
    'post_status' => 'publish',
    'posts_per_page' => 4,
    'cat' => $kategori,
    'date_query'    => array(
            array(
                'after'     =>  date('Y-m-d'),
                'before'    => date('Y-m-d') . ' 23:59',
                'inclusive' => true,
            ),
        ),
    
    );
  • 02-02-2024, 04:12:36
    #6
    Allah razı olsun süper çalıştı.
  • 02-02-2024, 07:40:23
    #7
    uygundolap adlı üyeden alıntı: mesajı görüntüle
    Allah razı olsun süper çalıştı.
    Senden de razı olsun işine yaradığına sevindim.