簡體   English   中英

使用 PODS 通過查詢顯示來自 pod 的變量

[英]Display a variable from a pod via query using PODS

我有一個帶有這些變量的自定義事件窗格:url,日期,時間

到目前為止,此代碼正在運行:

    <?php 
    $args = array( 
    'orderby' => 'date',
    'post_type' => 'event',
    );
    $the_query = new WP_Query( $args );
    
    if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>   

    <div><?php the_field('title');?></div>

    <?php endwhile; else: ?> <p>Sorry. Calendar not up-to-date.</p> <?php endif; ?>

呼應每個事件的標題是有效的,但我如何獲得其他變量(“日期、時間和 url”)?

我是這樣解決的:

<?php 
$args = array( 
'orderby' => 'datum',
'post_type' => 'event',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
       array(
           'key' => 'datum',
       )                   
)
);
$the_query = new WP_Query( $args );
    
if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
        
  global $post;
  $tours = pods('event', $post->ID);
  $datum = $tours->display('datum');
  $time = $tours->display('time');
  $url = $tours->display('url');

[... show some div and print some variables...]
        
endwhile; else: ?> <p>Sorry. Calender not up-to-date.</p> <?php endif; ?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM