Wrong date for post_date with get_the_date
-
I would like to display a custom list of event posts on a page, where the publish date is also displayed. For this I use, or rather the theme I use, the function get_the_date.
But this function is overridden by you with a hook and returns the event start date instead:
//Override post template tags add_filter('get_the_date',array('EM_Event_Post','the_date'),10,3); ... public static function the_date( $the_date, $d = '', $post = null ){$post = get_post( $post ); if( $post->post_type == EM_POST_TYPE_EVENT ){ $EM_Event = em_get_event($post); if ( '' == $d ){ $the_date = $EM_Event->start()->i18n(get_option('date_format')); }else{ $the_date = $EM_Event->start()->i18n($d); } } return $the_date; } ... public function start( $utc_timezone = false ){ return apply_filters('em_event_start', $this->get_datetime('start', $utc_timezone), $this); }But that is the wrong use of this function, because according to WordPress Codex with get_the_date always the publish date is meant!
This should definitely be changed!
The topic ‘Wrong date for post_date with get_the_date’ is closed to new replies.