1

我有一个带有这些变量的自定义事件 pod: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”)?

4

1 回答 1

0

我是这样解决的:

<?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; ?>
于 2020-12-01T12:11:47.003 回答