[英]Display a variable from a pod via query using PODS
I have a custom event-pod with these variables: url, date, time我有一个带有这些变量的自定义事件窗格:url,日期,时间
So far this code is working:到目前为止,此代码正在运行:
<?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; ?>
Echoing the title of each event is working, but how do I get the other variables ("date, time and url")?呼应每个事件的标题是有效的,但我如何获得其他变量(“日期、时间和 url”)?
I solved it this way:我是这样解决的:
<?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.