The Genesis Framework bundles a number of useful shortcodes that allow you to access and output important pieces of information quickly. One of these is for accessing the date that a Post or Page was originally published.
An extra benefit is that if you’re on an HTML5 Genesis theme, this shortcode not only produces the publish date but also marks it up with a semantic element and schema.org microdata.
The shortcode to access the publish date of any Post or Page is
This shortcode is employed by default in the entry meta, but you can actually use it wherever you like, such as the Post or Page title, the Post or Page body or the entry meta after the content.
As an example, below is the code to display the publish date after the content instead of before the content.
By default, Genesis will use your site’s preferred date format as per Settings > General, but it gives you the option of specifying a custom date format. As an example, you might choose to simply display the year that your Post or Page was published. Add to your shortcode
Y outputs the year; replace this with whichever date format you need).
Instead of displaying a date, Genesis gives you the option of displaying a relative time difference – e.g. . All you need to do is add
format="relative" to your shortcode.
before – Text to insert immediately before the date.
after – Text to insert immediately after the date.
format – The date format to use, either expressed using the WordPress date format standard or
relative to display a relative time difference.
Default: the preferred format as per Settings > General
[post_date] outputs the following in order:
<time class="entry-time" datetime="X" itemprop="datePublished">(HTML5) or
<span class="date updated time" title="X">(XHTML), where
Xis the ISO 8601 standard
- the text passed to the before attribute, if any
- the publish date, in the format specified in the format attribute
- the text passed to the after attribute, if any
There is one filter on the output of this shortcode, which is
genesis_post_date_shortcode. The entire marked up date passes through this filter before being output.
Genesis Simple Edits
[post_date] has been included since version 1.1.0.
[post_date] is located in lib/shortcodes/post.php.