Using the {get} Merge Tags with [gvlogic] to display a person's name in a Custom Content widget
This walk-through will show you how to use {get} Merge Tags together with the [gvlogic] shortcode.
Here's a quick demonstration
If you learn better with video, here's a quick walk-through:
Add a Custom Content widget
In the Widget area, click "+ Add Widget"
![The Add Widget button](https://www.gravitykit.com/wp-content/uploads/2018/01/add-a-custom-content-widget.png?1444882828)
Then click the Custom Content widget.
![The Custom Content widget in the widget list](https://www.gravitykit.com/wp-content/uploads/2018/01/c40eca28-2fa6-4b67-b4bc-fe9dcf10bed6.png?1444882830)
and click the gear icon to configure the Widget settings.
![The gear icon next to the Custom Content widget label](https://www.gravitykit.com/wp-content/uploads/2018/01/2caa9f89-d780-41ad-a476-42ec2e4b5ded.png?1444882830)
Add the following content to the widget:
[gvlogic if="{get:first-name}" isnot=""] <h3>Hi, {get:first-name}! Welcome to my View!</h3> [else] <h3>Welcome to my View!</h3> [/gvlogic]<br>
What will this do?
If a person's first name is passed in the URL using ?first-name
, it will show the person's name in the heading. If ?first-name
is not set or is empty, it will show a different heading.
![the [gvlogic] shortcode inside the Custom Content text editor](https://www.gravitykit.com/wp-content/uploads/2018/01/add-the-following-content-to-the-widget-.png?1444882831)
Update the View
Then visit the new View on your site.
![The Update button in the View editor](https://www.gravitykit.com/wp-content/uploads/2018/01/update-the-view.png?1444882832)
What is visible when there is nothing passed in the URL
The [else]
value is used when the {get}
value isn't matched.
![The browser address bar](https://www.gravitykit.com/wp-content/uploads/2018/01/what-is-visible-when-there-is-nothing-passed-in-the-url.png?1444882833)
When URL parameters are passed
?first-name=Floaty
content the URL triggers the {get:first-name}
Merge Tag.
Let's look at the [gvlogic]
shortcode we added to the Custom Content widget. It says if {get:first-name}
is not empty, show the following HTML content: <h3>Hi, {get:first-name}! Welcome to my View!</h3>
.
The {get:first-name}
content is then replaced with the value passed in the URL: Floaty!
![Hi Floaty, welcome to my View](https://www.gravitykit.com/wp-content/uploads/2018/01/when-url-parameters-are-passed.png?1444882834)