WordPress knowledge sharing

WordPress Article Last Updated Date_GeneratePress Theme Article Last Modified Date

WordPress Theme Article Last Updated There are many display methods of, which can be implemented with plug-ins or manually added code. These methods are also suitable for all Wordpress topics. In this article, the old Wei Yi Latest revision date of the GeneratePress theme article For example, explain why to display the latest update time of the article and how to display the latest update date in the Wordpress topic.

WordPress themed articles have two parameters: the release date and the latest update date (articles in this parameter include post types such as articles/pages/customizations, and articles refer to all forms by default). The search results based on the search engine will show the time. From the perspective of visitors, we can change the time of article publishing to the latest update time. This is what Google and domestic search engines show.

Since there is a difference between the article release time and the latest update time. The display of the latest update time will have the following benefits:

  • To ensure that visitors get the latest updated content;
  • Let the search engine display the last modification date in the SERP;
  • Increase blog click rate (CTR);

SERP: search engine result page, as shown in the following figure;

 The search results of Google and domestic search engines show the release time of the article

The search results of Google and domestic search engines show the release time of the article

WordPress stores the release date and modification date of the article in the database. If you do not use the latest update date function in WordPress, no matter how many times you update the article, only the release date of the article will be displayed instead of the update date. In order for website users to get the latest version of content and display the latest update date in the SERPs of Google or other search engines, you need to add the update date function to your blog to help improve the site's click through rate (CTR).

Two core 4G memory and 3M bandwidth are selected for the theme and plug-in of foreign website construction, which can run smoothly.
Domestic servers: Alibaba Cloud Tencent Cloud (All have vouchers, which can be used to save money when paying), I don't know how to select regions and configurations. Please add Lao Wei's contact information on the right side of the page. Let's study it together.

Foreign trade websites, B2C/C2C, etc. suggest registering domain names abroad. open Namesilo official website , enter the domain name to be registered in the search box, select it and then register. Remember to use the discount code to save money before paying. Discount code click Course of domain name registration of foreign domain name provider Namesilo obtain.

Suggested choice of foreign trade website Hostinger virtual host , the price is cheap and the performance price ratio is very high! Hostinger topic
SiteGround virtual host Moderate price, good service! SiteGround Theme

Use the WP Last Modified Info plug-in to display the latest update date

If you don't know how to add code manually and maintain later, it is obviously the fastest and easiest to use plug-ins.

WP Last Modified Info plug-in It's just such a plug-in. If you are interested, I suggest you go and have a look. This plug-in is enough, and it is applicable to all WordPress themes

If you don't want to use this plug-in, you can try the following methods.

Use the Code Snippets plug-in to display the latest update date

The Code Snippets plug-in is a WordPress management custom code plug-in, suitable for students who often add code to functions.php. If you have used this plug-in before, don't use the one above, just use the Code Snippets plug-in.

Why use this plug-in? If your WordPress website has been running for a long time, you will find that there are always such needs, which need to be added to functions. php. So if you can have such a plug-in, you can easily add and manage many codes.

We search for Code Snippets in WordPress Dashboard>Plug in>Install Plug in, install and enable them.

Click add new in the Code Snippets plug-in to give a name to the code fragment, copy and paste the following code in Code, and enter comments in Description so that later maintenance can know the purpose of this code. Click the save and activate button.

Three codes showing the latest update date

Insert the following three codes in the Code Snippets plug-in for us to display the latest update date under different circumstances.

Lao Wei tips:

1. These three codes are only applicable to the GeneratePress theme (you can modify them if you understand the code). If you use other themes, you can also use the WP Last Modified Info plug-in mentioned above to set them;

2. Change the code "published on" to "published on", and "last updated on" to "recently updated on", which can be used on Chinese WordPress websites. Lao Wei passed the test;

3. Change to the latest update date, the latest modification date, the latest update date, the latest modification date. Barabara can choose according to his personal preference;

1、 "Last Updated on" is displayed every time, that is, whether the article has been modified/updated, the article will display Last Updated on.

 add_filter( 'generate_post_date_output', function( $output, $time_string ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; if ( get_the_time( 'U' ) !==  get_the_modified_time( 'U' ) ) { $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %4$s</time>'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); return sprintf( '<span class="posted-on">%s</span> ', $time_string ); }, 10, 2 );

2、 The following code snippet compares the article release date with the update date, and it should only show updated if there is a date difference. If the article is the latest, "Published on" will be displayed, and when the article is updated, "Last Updated on" will be displayed.

 add_filter( 'generate_post_date_output', function( $output, $time_string ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time>'; if ( get_the_date() !==  get_the_modified_date() ) { $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %4$s</time>'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); return sprintf( '<span class="posted-on">%s</span> ', $time_string ); }, 10, 2 );

3、 The display shows both the release date and the last update date. If you want to display both the Release Date and the Last Updated Date in the GeneratePress topic, use the following code:

 add_filter( 'generate_post_date_output', function( $output, $time_string ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; if ( get_the_date() !==  get_the_modified_date() ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time> | <time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %4$s</time>'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); return sprintf( '<span class="posted-on">%s</span> ', $time_string ); }, 10, 2 );

After the latest update date is displayed in the Wordpress theme or GeneratePress theme by using plug-ins or adding code, you can view the time display in the search results after submitting the search engine update.

Lao Wei's comments

WordPress article last updated date The setting of has many benefits, which can not only increase the attention of search engines, but also attract users to click. What we need to do is to use plug-ins or add a piece of code according to personal circumstances. The code in the text is suitable Latest revision date of the GeneratePress theme article Function use, if you understand the code can also be modified to suit your theme.

Like( two )
Article name: WordPress Article Latest Update Date_GeneratePress Theme Article Latest Modification Date
Article link: https://www.vpsss.net/23824.html
Copyright notice: The resources of this website are only for personal learning and exchange, and are not allowed to be reproduced and used for commercial purposes, otherwise, legal issues will be borne by yourself.
The copyright of the pictures belongs to their respective creators, and the picture watermark is for the purpose of preventing unscrupulous people from stealing the fruits of labor.