Skip to content

Instantly share code, notes, and snippets.

@davemac
Created December 2, 2014 09:10
Show Gist options
  • Save davemac/e1bfc6954c894c4fb6c6 to your computer and use it in GitHub Desktop.
Save davemac/e1bfc6954c894c4fb6c6 to your computer and use it in GitHub Desktop.
WordPress show button if event start date is before today's date
function register_button() {
$output = '';
$current_date = date_i18n('Y-m-d');
$date = DateTime::createFromFormat('jS F, Y', get_field('dmc_conference_date'));
$moddate = $date->format('Y-m-d');
if ( $moddate < $current_date ) :
$output .= '<a href="/pre-register-for-a-conference/" class="button radius large right">Pre-Register for 2015</a>';
else :
$output .= '<a href="' . esc_url(get_field('dmc_conference_rego_link')) . '" class="button radius large right">Register Now</a>';
endif;
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment