我有一个名为'电影'的自定义帖子类型在该帖子类型中,我有几个元数据字段,其中一个被称为'已发布'。我要做的是列出电影'发布的帖子'例如yyyy-mm-dd日期格式。这是我到目前为止尝试的代码:
<?php $args = array(
'post_type' => 'movies',
'post_status' => 'publish',
'orderby' => 'meta_value_date',
'meta_key' => 'released',
'meta_type' => 'DATE',
'order' => 'ASC'
);
?>
<?php $query = new WP_Query( $args ); ?>
<?php if ( $query->have_posts() ) : ?>
<?php bd_pagination(); ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="panel panel-default panel-body">
<p class="fa fa-calendar"></p> <?php the_time( 'd-m-Y' ); ?> | <p class="fa fa-clock-o"></p> <?php the_time( 'H:i a' ); ?> | <p class="fa fa-user"></p> <a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>"><?php the_author(); ?></a></i> | <p class="fa fa-envelope-o"></p> posted in movies
<article class="post <?php if ( has_post_thumbnail() ) { ?>has-thumbnail <?php } ?>">
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'image-poster' ); ?></a>
</div>
<article class="post-thumbnail-text">
<h4 class="align_Center" style="color:#000; padding-bottom:1em;"><?php the_title(); ?></h4>
<?php
$nam = get_post_meta( get_the_ID(), "name", true );
$rel = get_post_meta( get_the_ID(), "released", true );
$rat = get_post_meta( get_the_ID(), "rating", true );
$dur = get_post_meta( get_the_ID(), "duration", true );
$gen = get_post_meta( get_the_ID(), "genre", true );
$dir = get_post_meta( get_the_ID(), "director", true );
$wri = get_post_meta( get_the_ID(), "writer", true );
$sta = get_post_meta( get_the_ID(), "stars", true );
$sto = get_post_meta( get_the_ID(), "storyline", true );
?>
<div class="align_Left">
<p><b>Title:</b> <?php echo $nam; ?></p>
<p><b>Released:</b> <?php echo $rel; ?></p>
<p><b>Rating:</b> <?php echo $rat; ?>/10</p>
<p><b>Duration:</b> <?php echo $dur; ?> min</p>
<p><b>Genre:</b> <?php echo $gen; ?></p>
<p><b>Director/s:</b> <?php echo $dir; ?></p>
<p><b>Writer/s:</b> <?php echo $wri; ?></p>
<p><b>Stars:</b> <?php echo $sta; ?></p>
<p><b>Storyline:</b> <?php echo $sto; ?></p>
</div>
<?php wp_reset_postdata() ?>
</article>
</article>
</div>
希望有人可以提供帮助 史蒂芬