Display Event Start Date
Filipe created the topic: Display Event Start Date
Hello, in my site I must have a function showing all events in a list, I was able to show the event title by the folowing code, but how do I show the event start date?
The code I'm using:
<?php
$the_query2 = new WP_Query('post_type=ecwd_event&posts_per_page=7');
while ($the_query2->have_posts()) :
$the_query2->the_post();
?>
<li>
<i class="fa fa-angle-double-right"></i>
<a href="<?php the_permalink(); ?>">
<?php echo get_the_title(); ?>
</a>
</li>
<?php endwhile; wp_reset_postdata(); ?>
Tanks for the help!!!
Please Log in or Create an account to join the conversation.
8 years 9 months ago
Support replied the topic: Display Event Start Date
Dear Filipe,
Please use the following code instead:
<?php
$the_query2 = new WP_Query('post_type=ecwd_event&posts_per_page=7');
while ($the_query2->have_posts()) :
$the_query2->the_post();
$start_date = get_post_meta(get_the_ID(), 'ecwd_event_date_from', true);
$end_date = get_post_meta(get_the_ID(), 'ecwd_event_date_to', true);
?>
<li>
<i class="fa fa-angle-double-right"></i>
<a href="<?php the_permalink(); ?>">
<?php echo get_the_title(); ?>
</a>
</li>
<?php endwhile; wp_reset_postdata(); ?>
Thank you.
Best regards,
Web-Dorado team
Joomla extensions ,
Wordpress plugins ,
Drupal modules
Please Log in or Create an account to join the conversation.
8 years 9 months ago
Filipe replied the topic: Display Event Start Date
Thanks for the reply, the code worked just fine, but I want do display only the date in the d/m/y format, the code you sent is displaying the hour too.
Thanks a lot!
Please Log in or Create an account to join the conversation.
8 years 9 months ago
Support replied the topic: Display Event Start Date
Dear Filipe,
Here's the necessary code:
$start_date = get_post_meta(get_the_ID(), 'ecwd_event_date_from', true);
$start_date = date('d/m/y', strtotime($start_date));
Please implement the same for end date.
Thank you.
Best regards,
Web-Dorado team
Joomla extensions ,
Wordpress plugins ,
Drupal modules
Please Log in or Create an account to join the conversation.
8 years 9 months ago
Filipe replied the topic: Display Event Start Date
Last question, how do I order the loop by this date?
Thanks for the help!
Please Log in or Create an account to join the conversation.
8 years 9 months ago
Support replied the topic: Display Event Start Date
Dear Filipe,
Please write the following instead of your query:
$the_query2 = new WP_Query('post_type=ecwd_event&posts_per_page=7&order=ASC&orderby=meta_value&meta_key=ecwd_event_date_from');
Thank you.
Best regards,
Web-Dorado team
Joomla extensions ,
Wordpress plugins ,
Drupal modules
Please Log in or Create an account to join the conversation.
8 years 9 months ago
Filipe replied the topic: Display Event Start Date
You are awesome, everything worked just fine.
Thanks a lot for the fast reply and the attention!
Please Log in or Create an account to join the conversation.
8 years 9 months ago
Support replied the topic: Display Event Start Date
Dear Filipe,
Thank you for your kind feedback. Please feel free to let us know in case you have any other questions.
Thank you.
Best regards,
Web-Dorado team
Joomla extensions ,
Wordpress plugins ,
Drupal modules
Please Log in or Create an account to join the conversation.
8 years 9 months ago