我已经创建自定义后类型在WordPress的事件,现在我想从我的页面模板,我叫活动自定义元框列出所有与值一起。
从元框的值被重复,这是遵循的模式:
最新帖子是好的,
较早的帖子显示,从最新帖子的meta框的值和,
等等。
这到底是怎么回事的截图:
这是一个查询,显示的帖子:
<?php
/*
Template Name: Event
*/
?>
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
if ( get_post_meta($post->ID, '_ct_hdr_value') ) : ?>
<div class="page-name innerpage<?php echo $post->post_name; ?>">
<div class="row">
<div class="twelvecol">
<h1 class="page-h1"><?php the_title(); ?> </h1>
</div>
</div>
</div>
<?php endif;?>
<div class="row">
<div class="page-container">
<div class="row">
<div class="content twelvecol">
<?php echo the_content();
endwhile;
endif; ?>
</div>
</div>
<section class="events cf">
<h3 class="fancy"><span>Upcoming events</span></h3>
<ul id="office-list" class="cf">
<?php
query_posts(array('post_type' => 'event', 'posts_per_page' => 30) );
if (have_posts()) : while (have_posts()) : the_post();?>
<li class="sixcol cf">
<article class="event cf">
<a class="cf" href="<?php echo the_permalink(); ?>">
<h5 class="text-center"><?php the_title(); ?></h5>
</a>
<br>
<a class="cf" href="<?php echo the_permalink(); ?>">
<?php the_post_thumbnail('full', array( 'class' => 'img-center img-responsive event-thumb')); ?>
</a>
<?php the_content() ?>
<section class="event-details">
<section class="event-address cf">
<?php
$adress = $address = $date = $city;
if (get_post_meta($post->ID, '_event_date_value',true) ) {
echo $date. '<i class="fa fa-calendar"></i> ',
$date = get_post_meta($post->ID, '_event_date_value', true);
echo '<br>';
}
if (get_post_meta($post->ID, '_event_address_value',true) ) {
echo $address. '<i class="fa fa-map-marker"></i> ',
$address = get_post_meta($post->ID, '_event_address_value', true);
}
if (get_post_meta($post->ID, '_event_city_value',true) ) {
echo $city. ', ',
$city = get_post_meta($post->ID, '_event_city_value', true);
}
?></section>
</section>
</article>
</li>
<?php
endwhile;
endif; ?>
</ul>
</section>
</div>
</div>
<?php get_footer(); ?>
一个PHP新手任何建议是欢迎。 :)