# Post Title, Date and Author Shortcodes

> Adds [post_title], [post_date], [post_modified], [post_author] and [post_url] shortcodes for templates, patterns and widgets that need details of the current post.

- Type: PHP
- Runs: Run everywhere
- Category: [Content](https://wpide.com/library/category/content/)
- Tags: shortcode, posts, dates
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/post-info-shortcodes/

## Code

```php
add_shortcode( 'post_title', function () {
    return esc_html( get_the_title() );
} );

add_shortcode( 'post_date', function ( $atts ) {
    $atts = shortcode_atts( array( 'format' => '' ), $atts, 'post_date' );

    return esc_html( get_the_date( $atts['format'] ) );
} );

add_shortcode( 'post_modified', function ( $atts ) {
    $atts = shortcode_atts( array( 'format' => '' ), $atts, 'post_modified' );

    return esc_html( get_the_modified_date( $atts['format'] ) );
} );

add_shortcode( 'post_author', function () {
    $post = get_post();

    return $post ? esc_html( get_the_author_meta( 'display_name', $post->post_author ) ) : '';
} );

add_shortcode( 'post_url', function () {
    return esc_url( get_permalink() );
} );
```

## Notes

Date shortcodes accept a format, for example [post_date format="j F Y"].

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Post Title, Date and Author Shortcodes" 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/
