Created
April 26, 2020 16:54
-
-
Save premanshup/e7eb60bed7f9cfc456e8f98d74b3c528 to your computer and use it in GitHub Desktop.
Add string before Date in meta data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add prefix to your Date String. | |
* | |
* @param string $output Markup date. | |
* | |
* @return void | |
*/ | |
function your_prefix_post_date( $output ) { | |
$output = ''; | |
$format = apply_filters( 'astra_post_date_format', '' ); | |
$time_string = esc_html( get_the_date( $format ) ); | |
$modified_date = esc_html( get_the_modified_date( $format ) ); | |
$posted_on = sprintf( | |
esc_html( '%s' ), | |
$time_string | |
); | |
$modified_on = sprintf( | |
esc_html( '%s' ), | |
$modified_date | |
); | |
$output .= '<span class="posted-on">'; | |
$output .= '<span class="published" itemprop="datePublished"> ' . $posted_on . '</span>'; | |
$output .= '<span class="updated" itemprop="dateModified"> ' . $modified_on . '</span>'; | |
$output .= '</span>'; | |
return 'Update on ' . $output; | |
} | |
add_filter( 'astra_post_date', 'your_prefix_post_date' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment