自定义文件的Wordpress自定义帖子

时间:2016-07-22 04:57:08

标签: wordpress custom-post-type

我有自定义帖子类型和自定义字段:expired_date 我想显示帖子没有过期,所以基本上我想检查一下expired_date > current_date,帖子会显示。

如何执行此WordPress循环查询?

<?php
    $args = array(
        'post_type' => 'job_listing'

    );

    query_posts($args);
    ?>
        <?php while (have_posts()) : the_post(); ?>

您能帮我解决一下如何在自定义帖子查询中查看。

1 个答案:

答案 0 :(得分:0)

$today = date('Ymd');
$args = array(
    'post_type' => 'job_listing',
    'meta_key' => 'the_date',
    'meta_query' => array(
        array(
            'key' => 'the_date',
            'value' => $today,
            'compare' => '>='
        )
    ),
    'orderby' => 'meta_value_num',
    'order' => 'ASC'
);

$your_custom_query = new WP_Query($args);

希望有所帮助:)