[post_id]

The shortcode to display the current post’s ID.


Product


Shortcode Attributes

  1. label – A string that will be displayed as a label before the post ID. If not provided, no label will be shown.
    • Options: Any text value

Shortcode Enclosed Content

Any content placed between [post_id] and [/post_id] will be used as a template, where {content} acts as a placeholder for the post ID.


Example Usage

[post_id]
[post_id label="Post ID:"]
[post_id]The ID of this post is: {content}[/post_id]

Results

Example 1:
Display Post ID Without a Label: 123 (where 123 is the ID of the current post)

Example 2:
Display Post ID With a Label: Post ID: 123

Example 3:
Display Post ID With Custom Content: The ID of this post is: 123
The shortcode will only work within the loop where get_the_ID() can retrieve the post ID.
If no post ID is found, the shortcode will output nothing.