Skip to content

Instantly share code, notes, and snippets.

@premanshup
Created April 26, 2020 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save premanshup/e7eb60bed7f9cfc456e8f98d74b3c528 to your computer and use it in GitHub Desktop.
Save premanshup/e7eb60bed7f9cfc456e8f98d74b3c528 to your computer and use it in GitHub Desktop.
Add string before Date in meta data.
/**
* 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