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

How to display the post publication date in WordPress ?

Add microdata tag itemprop timecode function

I've recently been optimizing the WordPress theme I plan to use for Chen Weiliang's blog.

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.

The HTML5 microdata specification is a way to mark up content to describe specific types of information, such as comments, people information, or events. Each type of information describes a specific type of item, such as a person, event, or comment. For example, an event might include attributes like `venue`, `starting time`, `name`, and `category`.

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):

October 2, 2017

<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 are marked with * .

Scroll to Top