我創建了一個自定義型別,在我的議程頁面中顯示不同的事件。 我的自定義型別使用一個日期欄位(通過ACF)。 我按日期(ACF欄位)排列我的事件網格
。我想在事件日期結束后自動關閉(在網格中隱藏)事件。
我的代碼:
< div class="row" id="galerydate">
<?php
$paged = ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$loop = new WP_Query( array (
'post_type' => '日歷',
'post_per_page' => 8,
'meta_key' => 'date_du_concert',
'orderby' => 'meta_value'。
'order' => 'desc',
'paged' => $paged )
);
if ( $loop->have_posts() ) 。
while ( $loop->have_posts() ) 。$loop->the_post(); ?>。
<div class="col-md-3 col-6">
<div class="cardagenda">/span>
<?php //the_post_thumbnail('large', array('class' => 'cover-img')); ? >
<img src="< ? php echo get_the_post_thumbnail_url( null, 'large' ); ? >" class="cover-img wp-post-image">
<?php if (get_field('statut'))。?>.
<div class="statutagenda">< ? php the_field( 'statut' ); ?></div>
<?php endif; ? >
<div class="dateagenda">
<?php the_field( 'date_du_concert' ); ? >>
</div>
<div class="lieuagenda">/span>
<?php the_field( 'lieu_du_concert' ); ? >?
</div>
<div class="ticketagenda"/span>>
<? php $artiste = get_field( 'artiste' ); ? >
<?php if ( $artiste ) 。?>
<?php foreach ( $artiste as $post ) 。 ? >
<?php setup_postdata ( $post ); ?
<a href="< ? php the_permalink(); ? >">Infos & tickets</a>
<?php endforeach; ? >
<?php wp_reset_postdata(); ?>
<?php endif; ? >
</div>
</div>/span>
</div>/span>
<?php endwhile; ? >
<?php wp_reset_postdata()。
endif; ? >
uj5u.com熱心網友回復:
檢查這個頁面 https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters
在你的查詢引數中,你應該添加類似于:
的內容。'meta_key' => 'date_du_concert',
'meta_value' => date( "Ymd" ), //改變 "date_du_concert "的儲存方式。
'meta_compare' => '> '。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/332466.html
標籤:
