How Does WordPress Display Post Published Dates?Add microdata tag itemprop timecode function

WordpressHow to display the date of publication of an article?

Add microdata tag itemprop timecode function

Currently optimizingChen WeiliangThe WordPress theme the blog intends to enable.

It is found that the article templates of some WP themes do not display the date and time of article publication at the beginning of the article, so you need to manually add rich page summary information (microdata) to mark the itemprop time function code.

What is itemprop?

  • The role of itemscope, itemtype, itemprop attributes is to facilitate the identification of specific tags by search engine spiders.
  • itemprop=”属性名” Add a data item property whose name can be a word or a URL.
  • Rich snippets of search engine results.

HTML5 microdata specification, which is a markup content to describe specific types of information, such as comments,personinformation or events.Each type of information describes a specific type of item, such as a person, event, or comment.For example, an event can contain venue, starting time, name, and category properties.

The first

Display date and time:

2017年10月2日 00:56:00

<time datetime="<?php echo get_the_date(__('Y-m-d\TH:i:sP', 'bunyad')); ?>" itemprop="datePublished"><i class="fa fa-clock-o"></i>
<?php time_ago( $time_type ='posts' ); ?></time>

Second

Show date only (recommended):

December 2 2025

<time class="the-date" datetime="<?php echo esc_attr(get_the_time('c')); ?>" itemprop="datePublished"><i class="fa fa-clock-o"></i>
<?php echo esc_html(get_the_date()); ?></time>

Please choose whether to display the code of the date and time at the same time (the first type) or only the code of the date (the second type) according to your own needs.

Comment

Your email address will not be published. Required fields * Callout

Scroll to Top