我在这个教程中http://www.blogmarketingacademy.com/events-list-with-wordpress/试图在单页的WordPress网站上制作一个事件列表我遇到的问题只是显示"没有预定的事件!敬请关注。"但是我在WordPress帖子标签中有一些事件发布,并且已经在wordpress中创建了自定义字段
<div class="ShowSection" id="Show">
<div class="container">
<div class="wrapper">
<div class="showtitle">
<h2>Upcoming | <span style="color:#f0c808;">Show Dates</span></h2>
</div>
<?php
$timecutoff = date("Y-m-d");
$args = array(
'category_name' => 'events',
'orderby' => 'meta_value',
'meta_key' => 'eventsortdate',
'meta_compare' => '>=',
'meta_value' => $timecutoff,
'order' => 'DESC'
);
$my_query = new WP_Query($args);
if ($my_query->have_posts()) : while ($my_query->have_posts()) :
$my_query->the_post();
$eventdate = get_post_meta($post->ID, "eventdate", true);
$eventlocation = get_post_meta($post->ID, "eventlocation", true);
?>
<ul class="event-list" id="events">
<li>
<div class="date"><h2><?php echo $eventdate; ?></h2></div>
<div class="main-title-event"><p><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></p></div>
<div class="main-loction-event"><p><?php $eventlocation; ?></p></div>
</li>
</ul>
<?php endwhile; else: ?>
<ul id="events">
<li><?php _e('No Events Scheduled! Stay Tuned.'); ?></li>
</ul>
<?php endif; ?>
</div>
</div>
</div>
&#13;
答案 0 :(得分:1)
尝试设置 $ timecutoff =新日期(&#34; Y-m-d&#34;);
我认为你必须通过这个创建一个新的日期对象。告诉我它是否有效:)