I have WordPress theme and I use get_the_date function to display post data :
<?php echo get_the_date( 'M-d-y' ); ?>
But it seems it will be better to use get_option( 'date_format' ).
How can I display post data using get_option function?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI have WordPress theme and I use get_the_date function to display post data :
<?php echo get_the_date( 'M-d-y' ); ?>
But it seems it will be better to use get_option( 'date_format' ).
How can I display post data using get_option function?
Calling get_the_date( get_option('date_format') );
will return the exact same value as get_the_date();
this is because by default if a date format is not specified when the function is called it will use get_option('date_format');
as can be seen from the following snippet taken from the get_the_date()
function itself:
if ( '' == $d ) {
$the_date = mysql2date( get_option( 'date_format' ), $post->post_date );
} else {
$the_date = mysql2date( $d, $post->post_date );
}