【发布时间】:2017-03-12 09:32:57
【问题描述】:
我创建了一个名为 movies 的自定义帖子类型,并添加了一个电影元框,其中包含一些我希望在我的帖子中看到的关于我要添加到我的存档中的电影的选项。
问题是我可以让它查看一篇帖子中的所有元信息,但不能查看我在 single-movie.php 中查看的一部电影的特定元信息
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : 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 } ?> clearfix">
<article class="post-thumbnail">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('image-poster'); ?></a>
</article>
<article class="post-thumbnail-text">
<h4 class="align_Center" style="color:#000; padding-bottom:1em;"><?php the_title(); ?></h4>
<?php $posts = get_posts(array(
'post_type' => 'movies',
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids'
)
);
$nam = get_post_meta( $posts, "name", true );
$rel = get_post_meta( $posts, "released", true );
$rat = get_post_meta( $posts, "rating", true );
$dur = get_post_meta( $posts, "duration", true );
$gen = get_post_meta( $posts, "genrer", true );
$dir = get_post_meta( $posts, "director", true );
$wri = get_post_meta( $posts, "writer", true );
$sta = get_post_meta( $posts, "stars", true );
$sto = get_post_meta( $posts, "storyline", true );
?>
<div class="align_Left">
<p>Title:</p> <?php echo $nam; ?><br>
<p>Released:</p> <?php echo $rel; ?><br>
<p>Rating:</p> <?php echo $rat; ?><br>
<p>Duration:</p> <?php echo $dur; ?><br>
<p>Genre:</p> <?php echo $gen; ?><br>
<p>Director:</p> <?php echo $dir; ?><br>
<p>Writer:</p> <?php echo $wri; ?><br>
<p>Stars:</p> <?php echo $sta; ?><br>
<p>Storyline:</p> <?php echo $sto; ?>
</div>
</article>
</article>
</div>
<?php endwhile;
else :
echo '<p>NO CONTENT FOUND</p>';
endif; ?>
</div><!-- ./CONTAINER -->
<?php get_footer(); ?>
【问题讨论】: