简体   繁体   English

使用 PODS 通过查询显示来自 pod 的变量

[英]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.

相关问题 查询 MySQL 数据库并使用响应中的变量显示 - Query MySQL database and display using variable from response 无法使用 PostgreSQL 查询以 php 形式显示变量的完整值 - can't display a complete value from a variable in php form using PostgreSQL query 在查询中使用表单中的变量 - Using a variable from a form in a query 仅在使用PHP在Laravel中通过搜索找到查询时显示 - Display only if query is found via search in Laravel using php 通过php PDO仅显示查询的前3个匹配行 - Display only the first 3 matching rows from a query via php PDO 如何委派给简码功能以过滤当前用户使用Wordpress中的Pods Framework创建的Pod项 - How to delegate to a shortcode function in order to filter pod items created by the current user using Pods Framework in Wordpress 使用PHP查询db,通过AJAX获取结果作为变量,再次使用初始变量的值查询db - Using PHP to query db, fetch results via AJAX as variable, query db again using values of initial variable 通过htaccess从查询字符串中删除第一个变量 - Remove first variable from query string via htaccess 从 Wordpress(Pods 和事件日历)中的关系字段显示和排序帖子 - Display, and sort posts from a relationship field in Wordpress (Pods & The Events Calendar) 使用MySQLi在PHP中显示查询结果 - Using MySQLi to display results from query in PHP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM