Show "Last Updated" date instead of "Released" date in Astra Theme

exist Astra thematic by default, it will display the article's Release Datebut (not) Last update date Then it appears in the code for SEO respond in singing Schema markup is used. If you wish to display the front-end Last update date Instead of a release date, add custom code to enable this functionality.

Image [1] - How to show "Last Updated" date instead of "Released" date in Astra Theme

Here are the steps to do so.

Image [2] - How to show "Last Updated" date instead of "Released" date in Astra Theme

Show last updated date in article metadata

Image [3] - How to show "Last Updated" date instead of "Released" date in Astra Theme

The release date and update date are provided in the markup.

To be only in the article'smetadatadisplayed in Last update date, you can add the following code:

/**
 * Show last modified date in article metadata only.
 *
 * @param String $output The last modified date token.
 * @return void
 */
function your_prefix_post_date( $output ) {
$output = '';
$format = apply_filters( 'astra_post_date_format', '' );
$modified_date = esc_html( get_the_modified_date( $format ) );
$modified_on = sprintf(
esc_html( '%s' ),
$modified_date
);
$output . = '';
$output . = ' ' . $modified_on . '';
$output . = '';
return $output.
}
add_filter( 'astra_post_date', 'your_prefix_post_date' );

This code hides the Release Dateand display only Last update date. Website visitors will see the latest revision time.

Image [4] - How to show "Last Updated" date instead of "Released" date in Astra Theme

Display the "last updated" date in the date box of the blog archive page

If one wishes to be Blog archive page in the date box of the "Last Updated" Date, not Release Date, use the following code:

/**
 * Only the last modification date is displayed in the article box date format.
 *
 * @param String $output The marker for the last modified date.
 * @return void
 */
function astra_date_box_time( $output ) {
    $time_string = '<time class="entry-date published" datetime="%1$s"><span class="date-month">%2$s</span> <span class="date-day">%3$s</span> <span class="date-year">%4$s</span></time><time class="updated" datetime="%5$s">%6$s</time>';
    $output = sprintf(
        $time_string,
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_modified_date( 'M' ) ),
        
        
        
        esc_html( get_the_modified_date( ) )
    ).
    return $output.
}
add_filter( 'astra_date_box_time_format', 'astra_date_box_time' );

This code ensures that the date frame displayed in Last update dateThe

Image [5] - How to show "Last Updated" date instead of "Released" date in Astra Theme

Important Notes:

  • If you are going to be in the article page respond in singing date frame are shown in the Last update date, two codes need to be used.
  • Add the code to the subtheme(used form a nominal expression) functions.php file Center.

Why use child themes?

utilization Astra subtheme Allows you to make customizations without modifying the original code of the parent theme. This way, even if the parent theme is updated, all customization changes will not be lost.

Child themes help to better manage code and avoid conflicts with other plugins or themes. Custom code is isolated from the core functionality of the theme to ensure the independence and security of modifications.

summarize

exist Astra thematic After adding the custom code, you can easily implement the Show last updated date in article and date boxes. This way, both on individual post pages andBlog Archivepage, visitors are able to see the most accurate update time. Making changes using a child theme ensures that custom code is not affected by updates to the parent theme, helping to manage the site efficiently.

Latest Articles


Contact Us
Can't read the tutorial? Contact us for a free answer! Free help for personal, small business sites!
Customer Service
Customer Service
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
This article was written by: thieves will be rats and mice courage
THE END
If you like it, support it.
kudos124 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments