【问题标题】:Need Help on create a event listing in Wordpress?在 Wordpress 中创建事件列表需要帮助吗?
【发布时间】:2016-05-14 18:52:24
【问题描述】:

我将通过这个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>

【问题讨论】:

  • 您是否在帖子中创建了自定义字段?
  • 是的,我在帖子中创建了 2 个自定义字段,名为 $eventdate 和 $eventlocation。 @丹麦

标签: php wordpress custom-wordpress-pages


【解决方案1】:

尝试设置 $timecutoff = new date("Y-m-d");

我认为你必须通过这个创建一个新的日期对象。告诉我它是否有效:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-06
    • 2020-06-21
    • 2012-01-26
    • 1970-01-01
    • 2023-01-26
    • 1970-01-01
    相关资源
    最近更新 更多