I don’t manage to ake it work, I think this is due to some code already present….
My archive is build like this:
<?php while ( have_posts() ) : the_post(); ?>
<?php
### START display code here
include('parts/archive-body.php');
### END display code here
?>
<?php endwhile; ?>
The parts/archive-body
<?php
# show categories
$categories = get_the_term_list( $post->ID, 'ev_categories', '<p>', ', ', '</p>' );
$categories = strip_tags( $categories );
if ( strpos($categories,'arts and culture') !== false ) { $catID = 1; };
if ( strpos($categories,'business') !== false ) { $catID = 2; };
if ( strpos($categories,'community') !== false ) { $catID = 3; };
if ( strpos($categories,'education') !== false ) { $catID = 4; };
if ( strpos($categories,'sport') !== false ) { $catID = 5; };
# show locations
$locations = get_the_term_list( $post->ID, 'ev_locations', '<p>', ', ', '</p>' );
$locations = strip_tags( $locations );
#echo $locations ;
?>
<?php
$categorydate = '';
if( get_post_type() == 'events') {
$categorydate = '<div class="categorydate" style="float:right;">';
$dateto = simple_fields_value("ev_dateto");
$dateto = $dateto["ISO_8601"];
$dateto = date_create_from_format("Y-m-d",$dateto);
$datetom_uk = date_format($dateto, 'd-m-Y');
$dateto_uk_nice = date_format($dateto, 'jS M Y');
$categorydate .= 'ends '.$dateto_uk_nice."<br/>";
$categorydate .= '</div>';
$today = date("Y-m-d");
# see if the event is in the past and if so mark it as archive
$newdateto = date_format($dateto, 'Y-m-d');
if ($newdateto < $today) {
$archiveclass = ' archivedevent';
} else {
$archiveclass = '';
};
}
?>
<div class="post catbox<?php echo $catID; ?><?php echo $archiveclass; ?>" id="post_<?php the_ID(); ?>">
<div class="category">
<?php
echo $categories;
echo $categorydate;
if ($categories <> '') echo '<div class="clear"></div>';
?>
</div>
<h2><a href="<?php esc_url( the_permalink() ); ?>" title="Permalink to <?php the_title(); ?>" rel="bookmark"><?php echo short_title(); ?></a></h2>
<?php if ( has_post_thumbnail() ) { ?>
<?php if( get_post_type() == 'businesses') { ?>
<div class="bizthumb">
<a href="<?php the_permalink() ?>" class="thumb" title="<?php the_title(); ?>">
<?php
the_post_thumbnail('Thumbnail Biz', array(
'alt' => trim(strip_tags( $post->post_title )),
'title' => trim(strip_tags( $post->post_title )),
'class' => ''
));
?>
</a>
</div>
<?php } else { ?>
<div class="bizthumb">
<a href="<?php the_permalink() ?>" class="thumb" title="<?php the_title(); ?>">
<?php
the_post_thumbnail('post-thumbnail', array(
'alt' => trim(strip_tags( $post->post_title )),
'title' => trim(strip_tags( $post->post_title )),
'class' => ''
));
?>
</a>
</div>
<?php }
?>
<?php } else { ?>
<a href="<?php the_permalink() ?>" class="thumb colourblock<?php echo $catID; ?>" title="<?php the_title(); ?>"></a>
<?php }; ?>
<?php #the_excerpt(); ?>
<?php
# show the correct one liner
$oneliner = '';
if( get_post_type() == 'events') {
if (simple_fields_value("ev_eventoneliner") <> '') {
$oneliner = trim_to(simple_fields_value("ev_eventoneliner"),140);
$oneliner .= '<div class="viewmore"><a href="'. get_permalink($post->ID) . '">View more</a></div>';
} else {
$oneliner = get_the_excerpt();
}
} else {
if (simple_fields_value("bu_oneliner") <> '') {
$oneliner = simple_fields_value("bu_oneliner");
} else {
$oneliner = get_the_excerpt();
}
};
echo $oneliner;
?>
</div>
However I’ve seen in the functions this:
function custom_posts_where( $where, $query ) {
if (is_singular()) return $where;
if (($query->query_vars['post_type'] == 'events' || (is_array($query->query_vars['post_type']) && $query->query_vars['post_type'][0] == 'events'))) {
$year = 0;
$month = 0;
if (preg_match('@/([0-9]{4})/([0-9]{1,2})/@', $_SERVER['HTTP_REFERER'], $refer_match)) {
$year = $refer_match[1];
$month = $refer_match[2];
}
else if (preg_match('@/([0-9]{4})//@', $_SERVER['HTTP_REFERER'], $refer_match)) {
$year = $refer_match[1];
}
if (is_archive()) {
if (!is_month() && !is_year()) {
$where .= " AND wp_postmeta.meta_value >= now()";
}
else {
$where = preg_replace("@AND.*?\) \)@i", '', $where);
if (is_month() || is_year()) {
$where .= " AND YEAR(wp_postmeta.meta_value) = " . $query->query_vars['year'];
}
if (is_month()) {
$where .= " AND MONTH(wp_postmeta.meta_value) = " . $query->query_vars['monthnum'];
}
}
}
else if ($year > 0 || $month > 0) {
if ($year) {
$where .= " AND YEAR(wp_postmeta.meta_value) = " . $year;
}
if ($month) {
$where .= " AND MONTH(wp_postmeta.meta_value) = " . $month;
}
}
else {
if (!is_search || is_home() ) {
$where .= " AND wp_postmeta.meta_value >= now()";
}
#} else {
#$where .= " AND (wp_postmeta.meta_value = '_simple_fields_fieldGroupID_1_fieldID_5_numInSet_0' AND wp_postmeta.meta_value >= now())";
#meta_key '_simple_fields_fieldGroupID_1_fieldID_5_numInSet_0'
#meta_value '2013-10-28'
#}
}
}
return $where;
}
If i delete this function, I get all the post being display .
At the moment the custom post get “exclude” of the archive the day before the date field …. instead I need to have it “exclude” on the D-Day at 23:59 .. .
If you have time to help me around how should I manage this, It will be fantastic, I didn’t developed this theme, I would have done this in a very different way so I get confuse with it !!