开发者

Wordpress Event list

Hi I have followed a tutorial to create and event list in wordpress using post and Custom Fields view demo

here is my code:

    <?php // Get today's date in the right format
$todaysDate = date('M d');
?>
<?php query_posts('showposts=5&category_name=events&meta_key=Date&meta_compare=>=&meta_value='.$todaysDate.'&orderby=meta_value=order=ASC'); ?>

<ul>
<?php 
    if (have_posts()) : while (have_posts()) : the_post();
    $eventMeta = get_post_meta($post->ID, 'Date', true);
    $eventDate = strtotime($eventMeta);
    $displayDate = date ('M d', $eventDate);?>
<li>
<span class="date"><?php echo $displayDate ; ?></span>
    <span><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></span>
</li>
<?php endwhile; else: ?>
<li>Sorry, no upcoming events!</li>
<?php endif; ?>
</ul>
<?php wp_reset_quer开发者_高级运维y(); ?>

Now my problem is that it doesn't show any events for the future events e.g. (June, July etc. ...).

On one of the the discussion there someone had said about putting "In your query_posts, just use the parameter ‘post_status=future’ ".

Can you please let me know exactly where? I have added it but nothing happened.


According to the query posts docs ( Function Reference/query posts « WordPress Codex ), it goes in your query string &post_status=future like any other parameter. Try a simpler query posts string with &post_status=future and see if it works.


Custom fields are cool, but I wouldn't suggest using them for a full blown event manager. Consider looking at PodsCMS for WordPress. One of their first working examples is an event manager. The dev team is great and they're always helpful if you ever have problems.


There's also a plugin called The Future Is Now that overrides the default WordPress behavior of not showing posts until their publish date rolls around. Use that and you won't need any custom code to handle this situation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜