The Post Dynamic Shortcode can be used to get:
Essential information about a post like the date, the author etc.
Post metas and custom fields attached to a post.
Other data that is usually fetched in WordPress with a function like the excerpt.
The basic structure is {post:field-name}
This is all you need to get post meta and custom fields by passing their names as the first argument to the shortcode.
Get fields of other Posts
By default the post referred to is that current one. You can use the id
keyarg to refer instead to another WordPress post, for example the following will take field from post 42 {post:field-name@id=42}
.
Get field essential information
To get the publication date and author is very simple just use {post:date}
and {post:author}
. You can also use title, excerpt, featured_image, permalink, post_type and parent_id, but keep in mind that these will call the corresponding WordPress functions.
Getting all the post metas
Some post metas are specified more than once with different values. To get these you can specify the keyarg all, just add it to the list of keyargs {post:field-name@all}
, you will get back an array including all the metas related to the field.