繁体   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