我有一个活动列表网站,其中一个部分显示以前的所有活动。我需要从今天开始显示所有事件。我目前正在使用下面的代码显示所有事件的存档,但需要相应地修改它。任何帮助将不胜感激! “这是所有活动的存档”这里 - > http://www.1111presents.com/2014/events/
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$theTitle = "".__('Archive of All Events', 'eventful_theme')."";
if (get_query_var('period')) {
$theDate = preg_split("/-/", get_query_var( 'period' ));
if (isset($theDate[0]) && isset($theDate[1]) && isset($theDate[2]) ) {
$theTitle = __('Events on ','eventful_theme').strftime('%e %B %Y', mktime(0, 0, 0, (int) $theDate[1], (int) $theDate[2], (int) $theDate[0]));
$period_start = mktime(0, 0, 0, (int) $theDate[1], (int) $theDate[2], (int) $theDate[0]);
$period_end = mktime(23, 59, 59, (int) $theDate[1], (int) $theDate[2], (int) $theDate[0]);
} else { ?>
以下是其他查询代码:
<?php
}
}
if (get_query_var('artist_events')) {
$wp_query = new WP_Query(
array(
'post_type' => 'events',
'posts_per_page' => get_option('posts_per_page'),
'orderby' => 'meta_value_num',
'meta_key' => 'events_date_start_epoque',
'order' => 'ASC',
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'artists_tag',
'field' => 'slug',
'terms' => get_query_var('artist_events') ,
),
),
)
);
}
$wp_query = new WP_Query(
array(
'post_type' => 'events',
'posts_per_page' => get_option('posts_per_page'),
'orderby' => 'date',
'meta_key' => 'events_date_start_epoque',
'order' => 'DESC',
'paged' => $paged
)
);
?>
我把所有东西放在一起。
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$theTitle = "".__('Archive of All Events', 'eventful_theme')."";
if (get_query_var('period')) {
$theDate = getdate();
if (isset($theDate[0]) && isset($theDate[1]) && isset($theDate[2]) ) {
$theTitle = __('Events on ','eventful_theme').strftime('%e %B %Y', mktime(0, 0, 0, (int) $theDate[1], (int) $theDate[2], (int) $theDate[0]));
$period_start = mktime(0, 0, 0, (int) $theDate[1], (int) $theDate[2], (int) $theDate[0]);
$period_end = mktime(23, 59, 59, (int) $theDate[1], (int) $theDate[2], (int) $theDate[0]);
} else { ?>
<div class="dws_bg_dotted dws_margin_top_medium dws_margin_bottom_big">
<div class="container_24">
<div class="dws_bg_custom_text dws_general_padding">
</div>
</div>
</div>
<?php
}
}
$wp_query = new WP_Query(
array(
'post_type' => 'events',
'posts_per_page' => get_option('posts_per_page'),
'orderby' => 'date',
'meta_key' => 'events_date_start_epoque',
'order' => 'DESC',
'paged' => $paged,
'date_query' => array(
array(
'before' => array(
'year' => $theDate["year"],
'month' => $theDate["mon"],
'day' => $theDate["mday"],
),
),
)
)
);
?>
答案 0 :(得分:0)
这可能有助于您获得所需内容
$today = getdate();
$wp_query = new WP_Query(
array(
'post_type' => 'events',
'posts_per_page' => get_option('posts_per_page'),
'orderby' => 'date',
'meta_key' => 'events_date_start_epoque',
'order' => 'DESC',
'paged' => $paged,
'date_query' => array(
array(
'before' => array(
'year' => $today["year"],
'month' => $today["mon"],
'day' => $today["mday"],
),
),
)
)
);