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!
]]>i am trying to get the date in my wp bakery grid builder.
so far i have created a shortcode which functions but it echos back te page date.
<?php
function dotavatiar_function( $format = '', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
$_format = ! empty( $format ) ? $format : get_option( 'date_format' );
$the_date = get_post_time( $_format, false, $post, true );
/**
* Filters the date a post was published.
*
* @since 3.0.0
*
* @param string $the_date The formatted date.
* @param string $format PHP date format.
* @param int|WP_Post $post The post object or ID.
*/
return apply_filters( 'get_the_date', $the_date, $format, $post );
};
add_shortcode('dotiavatar', 'dotavatiar_function');
I want to get the posts-date. This function i have written above as i said echos the page date not the posts.
Thank you
]]>This is what I am doing:
$myposts = get_posts([
'post_type' => 'fiveminutespodcast',
'post_status' => 'publish',
'numberposts' => -1,
'orderby' => 'title',
'order' => 'ASC'
]);
foreach ( $myposts as $post ) :
$mytitle = get_the_title($post);
$url = get_permalink($post);
$date_time = get_the_date('M j, Y');
echo "<a href='$url'>$mytitle</a> ($date_time)<br>";
endforeach;
But this keeps pulling up the post_modified date – or so it seems.
]]>I am trying to get :itemprop=”datePublished” to show up whenever the get_the_date function runs, but all that happens is i seem to overide all the info that is in the get_the_date function.
here is an example of the code i have installed in my functions.php:
/* adds schema to post date */
add_filter('get_the_date', 'schema_get_the_date');
function schema_get_the_date($attr) {
$attr['itemprop'] = 'datePublished';
return $attr;
}
how can i get that itemprop to be able to appear next to the date the post was published so that it can register as schema?
]]>if(qtrans_getLanguage() == 'fr'){}...
and its always false even though I’m in the french version of my website.
<?php echo get_the_date(); ?>
is always blank. This affects all pages and widgets as well.
Any thoughts? I’m stumped. No errors are being logged.
]]>esc_html( get_the_date(j M.Y))
works just fine and looks like 26 Nov 2014 – all on one line.
But if I want to make it be something akin to:
26
Nov 2014
with 26 centered and larger than the month and year, I am not sure how to do that. Putting html in with the date codes does not work. Neither does using ‘ or / to prevent WordPress from interpreting the html as WordPress tags.
————-
Changing this info for the loop where the post snippets are listed works just fine by editing the loop, so I know it’s possible.
]]>Can anyone assist me in figuring out why the following is outputting “September 28, 2014” when in fact the current date (as of writing this) is “September 30, 2014”?
add_action( 'get_header', 'sk_set_date' );
function sk_set_date() {
// if ( date("l", strtotime('+10 hours')) == 'Tuesday' ) {
// if ( the_date( 'l' ) == 'Tuesday' ) {
// echo 'Today is Tuesday';
// }
echo get_the_date();
}
The site is on localhost via DesktopServer which uses MAMP.
I went ahead and changed the value of “date.timezone” to “Australia/Victoria” in php.ini.
phpinfo() shows the change: https://cl.ly/image/1a1s3l0H1J2B
Date settings in WordPress: https://cl.ly/image/263z220E2q0x
Any ideas?
]]>