# Article Published and Modified Date Meta Tags

> Adds article:published_time and article:modified_time meta tags to blog posts, which social networks and search engines use to understand how fresh a post is.

- Type: PHP
- Runs: Frontend only
- Category: [SEO](https://wpide.com/library/category/seo/)
- Tags: meta-tags, dates, open-graph
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/article-date-meta-tags/

## Code

```php
add_action( 'wp_head', function () {
    if ( ! is_singular( 'post' ) ) {
        return;
    }

    $post = get_queried_object();

    echo '<meta property="article:published_time" content="' . esc_attr( get_post_time( 'c', true, $post ) ) . '" />' . "\n";
    echo '<meta property="article:modified_time" content="' . esc_attr( get_post_modified_time( 'c', true, $post ) ) . '" />' . "\n";

    foreach ( get_the_category( $post->ID ) as $category ) {
        echo '<meta property="article:section" content="' . esc_attr( $category->name ) . '" />' . "\n";
        break;
    }
}, 6 );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Article Published and Modified Date Meta Tags" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
