0

I am using posts for listing my events. So i need to specify two different dates for my posts. I know there is only one post date, but i need to make it two to specify my events starting and ending dates. How is that possible? Or can you just recommend a plugin if there is?

Thanks...

1 Answer 1

1

Have you tried the basic Custom Fields that Wordpress includes automatically? If you don't see it at the bottom of your Post edit screen, click the Screen Options button at the top-right of your editor window and check the box next to Custom Fields to make it visible. Once you can see it at the bottom of the editor, click Add Custom Field and enter something like 'event_start' in the Name input, and your start date in the Value field. Repeat that step to create an 'event_end' field. When you create a new post, these fields will be available to you in the Select dropdown under Name.

To expose the start date in your page the visitor sees, use this in your template: <?php echo get_post_meta($post->ID, 'event_start', true); ?>.

Screen Options

3
  • also worth mentioning that if you plan to query on these dates, they should be stored as timestamps or descending units like yyyy-mm-dd
    – Milo
    Jan 5, 2018 at 5:51
  • i have added the custom field. and valued it as start date. and i need to specify ending date. do i have to create new custom value for ending date as well? i cannot change the post date with future date it wont publish like that. and finally, where will i put the code you have mentioned?
    – Sinan
    Jan 5, 2018 at 12:30
  • The Name of the first custom field would be start_date, the Value associated with that name would be the actual date of your event. The Name of the 2nd field would be end_date, and the value would be the actual date. The php code to display the date goes in your template, like single.php, inside the Loop.
    – Gary D
    Jan 5, 2018 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.