This members-only tutorial provides the steps to parse the text in a URL parameter or query variable and display its value on the page in Oxygen.

After implementing the steps in this tutorial, you can have the heading text show

"Hello Sri"

at

https://example.com/landing-page/?fname=sri

and

"Hello Louis"

at

https://example.com/landing-page/?fname=louis

Use Case

Most email marketing list providers provide an option to insert dynamic variables or tokens in the body of emails that you can blast to your list subscribers.

Let's say you launched a new product and want to make your list users feel special by displaying the user's first name on the product landing page.

You could build a link and append something like /?fname={first_name} in the URL where {first_name} is the token provided by your list provider that would dynamically replace it with the actual first name of the user that is going to receive the mail.

Now each user is going to see his/her first name next to "Hello" in the landing page header/body text.

Process

We are going to

  • add fname to the list of public query variables that WordPress can process
  • define a custom PHP function that displays the value of specified query variable (this will be sent in when calling this function), sanitizes it and converts the first letter to uppercase. Update: Added instructions to show a fallback text.
  • use the PHP Function Return value feature in Oxygen and call our function defined with fname as the input

Step 1

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: Add "fname" query variable

Code:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($27/month or $169 one-time).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE

Comments

For adding code blocks wrap the code in three backticks. Markdown should work.
Provide a URL of your site/webpage if something is not working.
  • magnifiercross
    >
    linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
    %d bloggers like this: