orbitgadget
Forum Replies Created
-
Forum: Plugins
In reply to: [WP Last Modified Info] Add Published date AND Updated date?Hey Keith, I have the ready-made code for Astra users. I would love to present it here.
//Example//
Before- “September 13, 2020 / By OrbitGadget”
After- “Last Updated on September 13, 2020, By OrbitGadget”The code is :
function your_prefix_post_date( $output ) {
$output = ”;
$format = apply_filters( ‘astra_post_date_format’, ” );
$modified_date = esc_html( get_the_modified_date( $format ) );
$updatetxt = “Last Updated on”;
$postedtxt = “Posted on”;
$u_time = get_the_time(‘U’);
$u_modified_time = get_the_modified_time(‘U’);
$modified_on = sprintf(
esc_html( ‘%s’, ‘%s’),
$modified_date
);if ($u_modified_time >= $u_time + 86400) {
$output .= ”;
$output .= ‘ ‘ . $updatetxt . ”;
$output .= ‘ ‘ . $modified_on . ”;
$output .= ”;
return $output;
}else {
$output .= ”;
$output .= ‘ ‘ . $postedtxt . ”;
$output .= ‘ ‘ . $modified_on . ”;
$output .= ”;
return $output;
}
}
add_filter( ‘astra_post_date’, ‘your_prefix_post_date’ );
add_filter( ‘astra_post_meta_separator’, ‘__return_false’ );Now for the implementation of the above code just paste it in the functions.php if you are using a child theme. If you are not using a child theme you can use the code snippet plugin and add the above snippet.