简体   繁体   中英

Display a variable from a pod via query using PODS

I have a custom event-pod with these variables: url, date, time

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")?

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; ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM