2017-09-05 93 views
0

我正在尋找一種在WP循環中創建'按日期排序'自定義按鈕的方法,該網站運行在_S主題下(確實從頭開始運行)。添加一個自定義的「按日期排序」按鈕WP

在下面的部分,我做了一個像this one這樣的過濾系統,但我也需要構建一個日期過濾系統。

在這個循環中,文章默認顯示(按日期DESC我猜?)。

我知道如何獲得WP功能的日期,但在此之後,Im掙扎了一下。

有什麼想法嗎?

THX :)

<div class="wrap-tags container"> 
     <div class="row"> 
      <ul class="filters"> 
       <li>Filtres</li> 
       <li><a href="javascript:void(0)" class="date">Date</a></li> 
       <li><a href="javascript:void(0)" class="trigger">Tags</a></li> 
      </ul> 
      <ul class="tags"> 
       <li><button class="link" data-rel="all" href="javascript:void(0)">ALL</button></li> 
       <li><button class="link" data-rel="un" href="javascript:void(0)">Un</button></li> 
       <li><button class="link" data-rel="deux" href="javascript:void(0)">Deux</button></li> 
       <li><button class="link" data-rel="trois" href="javascript:void(0)">Trois</button></li> 
       <li><button class="link" data-rel="quatre" href="javascript:void(0)">Quatre</button></li> 
      </ul> 
     </div> 
    </div> 

    <section class="container blog-article-actu"> 
      <div class="row"> 

    <?php 
    $the_query = new WP_Query('showposts=-1'); 

    while ($the_query->have_posts()) : 
    $the_query->the_post(); 
    $catObj = get_the_category(); 
    $get_the_tags = get_the_tags(); 

     ?> 

     <article class="blog-article-actu-article all <?php foreach ($get_the_tags as $leTab){ echo $leTab->name . " "; } ?>" style="background:url('<?php $url = wp_get_attachment_url(get_post_thumbnail_id($post->ID), 'thumbnail'); ?><?php echo $url ?>');"> 
      <div class="blog-article-actu-article-top"> 
       <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> 
       <div class="details-blog-article-actu"> 
        <div class="blog-article-actu-date"> 
         <span class="day"><?php the_time('d') ?></span> 
         <span class="month"><?php the_time('F') ?></span> 
        </div> 

       </div> 
      </div> 

     </article> 

    <?php // End of the loop. 
    endwhile; 
    ?> 

      </div> 
    </section> 

回答

0

如果有人仍然有興趣,在我的情況,我用jQuery的扭轉文章「騙」(雖然條款是按日期默認顯示)。