1
On the table wp_posts
, the data is like this :
and when I enter an event, other than this table above, goes data to wp_postmeta
, and stay like this:
in the file that displays the events is like this:
<div class="latest-events">
<?php query_posts('post_type=event&posts_per_page=3'); if (have_posts()) : while (have_posts()) : the_post(); ?>
<article class="latest-event cf">
<?php if(ale_get_meta('event_date')) { ?>
<time datetime="2014-08-09" class="date">
<?php $date_event = ale_get_meta('event_date');
$date_event_one = explode('/',$date_event); ?>
<span class="date__day"><?php echo date("d", mktime(0, 0, 0, $date_event_one[0], $date_event_one[1], $date_event_one[2])); ?></span>
<?php echo date("M", mktime(0, 0, 0, $date_event_one[0], $date_event_one[1], $date_event_one[2])); ?>
<span class="date__year"><?php echo date("Y", mktime(0, 0, 0, $date_event_one[0], $date_event_one[1], $date_event_one[2])); ?></span>
</time>
<!-- End date -->
<?php } else { ?>
<time datetime="2014-08-09" class="date">
<span class="date__day"><?php echo get_the_date('d'); ?></span>
<?php echo get_the_date('M'); ?>
<span class="date__year"><?php echo get_the_date('Y'); ?></span>
</time>
<!-- End date -->
<?php } ?>
<div class="latest-event__wrap">
<header class="latest-event__header">
<h1 class="latest-event__title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h1>
<?php $cur_terms = get_the_terms( $post->ID, 'event-category' );
if($cur_terms != '') { ?>
<p class="latest-event__category">
<?php
foreach($cur_terms as $cur_term){
echo ' '. $cur_term->name.' ';
}
?>
</p>
<?php } ?>
</header>
<!-- End event post header -->
<p><?php trim_content_chars(120,'...') ?></p>
</div>
<!-- End event post wrap -->
<a href="<?php the_permalink(); ?>" class="btn-more">+</a>
</article>
<!-- End event post-->
<?php endwhile; else: ?>
<?php ale_part('notfound')?>
<?php endif; wp_reset_query(); ?>
</div>
<!-- End Events posts -->
How to display events in descending order, with the date of the event going to the table wp_postmeta
, in the field meta_value
?
Got that way the way you said. I tested by changing the field to
meta_value
, and also did not work. Remembering that the date is in the fieldmata_value
, and the format is 10/07/2015. The day comes in the middle.query_posts('post_type=event&posts_per_page=7&orderby=date&order=DESC'); if (have_posts()) : while (have_posts()) : the_post();
– Hugo Senna