The {current_post} Merge Tag
Sometimes you want to embed information about the current page in a View (or Gravity Form). That's what the {current_post}
Merge Tag does.
{current_post}
is replaced with the current post's permalink by default, when no modifiers are passed. You can access any WP_Post variables:
{current_post:ID}
{current_post:post_title}
{current_post:post_type}
In addition, we have added a way to access the post or page's permalink (URL on your website):
{current_post}
or{current_post:permalink}
- Outputs a permalink to the current post or page
What's the difference between {current_post}
and {embed_post}
?
{current_post}
is the same as {embed_post}
, except:
- Adds support for fetching the permalink by using
{current_post}
or{current_post:permalink}
- Works on post archives (category archives, tag archives), as well as singular posts
See Gravity Forms' {embed_post} Merge Tag doc for examples.
You can use it with the Advanced Filter Extension
If you have a page that has a form embedded on it, and you want to embed a View on the same page that will only show the entries created by that form, you can use the Advanced Filter Extension to accomplish that.
To only show entries that were created on the current page, set the "Source URL" value to {current_post}
in the Filters tab of the View Settings metabox. It should look like this:
You can use it with the [gvlogic]
shortcode
If you want to display different content based on the page that is being displayed, you can use the [gvlogic]
shortcode inside Custom Content:
[gvlogic if="{current_post:ID}" is="49"]
This content will only show on the page with ID #49
[/gvlogic]