[post_permalink]
The shortcode allows you to dynamically generate links to posts or pages.
Product
Shortcode Attributes
- id – Post ID whose modified date you want to display.
- Options: Any valid post ID.
- title: The link text. If not specified, the URL of the link will be used.
- Options: Any text value.
- target – Specifies the target attribute for the link.
- Options:
_blank: Opens in a new tab or window._self(default): Opens in the same frame or tab._parent: Opens in the parent frame or tab._top: Opens in the main window, cancelling other frames.
- Options:
- classes – Specifies additional CSS classes for styling the link.
- label – A label above the modified date.
- Options: Any text value.
Shortcode Enclosed Content
Any content placed between [post_permalink] and [/post_permalink] will be used as a template, where {content} acts as a placeholder for the post permalink.
Example Usage
Example 1
[post_permalink title="Read More"]
Results
<a href="https://example.com/currentpage">Read More</a>
| This example returns a link to the current post with the text ‘Read More’. |
Example 2
[post_permalink id="123" target="_blank"]
Results
<a href="https://example.com/?post=123" target="_blank">https://example.com/?post=123</a>
This example returns a link to a post with ID 123, opening in a new tab. |
location_post or location_page type page, it will automatically retrieve the post ID from the link_to_location field if it exists.Example 3
[post_permalink label="Go to:" class="btn btn-primary"]
Results
<label>Go to:</label>
<a class="btn btn-primary" href="https://example.com/currentpage/">https://example.com/currentpage/</a>
This example returns a link with label and custom class. |
Example 4
[post_permalink id="456"]<div class="custom-link">{content}</div>[/post_permalink]
Results
<div class="custom-link">
<a href="https://example.com/?post=456">https://example.com/?post=456</a>
</div>
This shortcode generates a <div> element with the class custom-link, containing an <a> tag that links to the specified post with the ID 456. |