WordPress adds the update time to the top post

Source: Internet
Author: User

Generally, the top won't be the latest article, so I started my research and showed that I did a research on the attributes of post. I found that the following code shows the last update time:

 

The code is as follows: Copy code
<? Php $ id = // The ID of the article
$ Post_modified = get_post ($ id)-> post_modified;
Echo $ post_modified; // output the latest modification time of the current id article
?>

The following information can be obtained through get_post ($ id)->:

Post_author :( integer) number of the author of the article
Post_data :( character) post date and time (YYYY-MM-DD HH-MM-SS)
Post_data_gmt :( character) article published by Greenwich Mean Time (GMT) (YYYY-MM-DD HH-MM-SS)
Post_content: (character) content of the article
Post_title: (character) document title
Post_category: (integer) number of the document category. Note: The total number of versions after WordPress 2.1 is 0. You can use the get_the_category () function to define the document category.
Post_excerpt: (character) abstr
Post_status: (character) document status (publish | pending | draft | private | static | object | attachment | inherit | future)
Comment_status: (character) comment status (open | closed | registered_only)
Ping_status: (character) pingback/trackback status (open | closed)
Post_password: (character) password of the document
Post_name: (character) URL nesting of the article
To_ping: (character) URL link to be referenced
Pinged: (character) referenced link
Post_modified :( character) article last modified time (YYYY-MM-DD HH-MM-SS)
Post_modified_gmt :( character) Post Last modified GMT time (YYYY-MM-DD HH-MM-SS)
Post_parent: (integer) number of the parent article (for attachments, etc)
Guid: (character) a link to the article. Note: The GUID cannot be used as a permanent link (although it is indeed used as a permanent link in versions earlier than 2.5) or as a usable link to the article. GUID is a unique identifier, but it happens to be a link to the article.
Post_type: (character) (log | page | attachment)
Post_mime_type: (character) Mime type (for attachments, etc)
Comment_count :( integer) total comments
The problem also comes, post_modified :( character) the last modification time of the article (YYYY-MM-DD HH-MM-SS), there is time in it, I don't want time, it's hard for me, so I finally found the answer on the wordpress official website, just like this:

The code is as follows: Copy code


<? Php echo mysql2date ('Y-m-J', $ post-> post_modified);?>


Add the above code to the code for determining whether to pin index. php:

 

The code is as follows: Copy code
<H2 class = "entry-title">
<? Php if (is_sticky ():?>
<I class = "sticky sticky_ordinary"> </I>
<A href = "<? Php the_permalink ()?> "Rel =" bookmark "title =" read more <? Php the_title_attribute ();?> ">
<? Php the_title ();?> <Font style = "color: # f00;"> (on <? Php echo mysql2date ('Y-m-J', $ post-> post_modified);?> Update) </font>
</A>
<Span class = "new">
<? Php include ('Des/new. Php');?>
</Span>
</H2>

How about mysql2date!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.