Query in URL string help

So I’m writing a little function that should be easy, basically it should look at the query parameter in the URL string and show content if the query string has a value… it generates the correct URL with the query string (in this case, it dynamically assigns a referrer id to a facebook post, then when a user clicks on the post it shows some additional content). But it doesn’t show the content… what am I missing?

<note>hardcoding referrer for now</note>

<Set referrer>1234</Set> 
<Set sharer><Url current />/?referrer=<Get name=referrer /></Set>

<a href="https://www.facebook.com/sharer.php?u={Get name=sharer /}">SHARE ON FACEBOOK</a>

All of the above works. When the facebook post is clicked on it passes the correct page URL with the query string /?referrer=1234.

The code below should read the query string and then show the content on the page given the referrer has a value.

<Set refid><Url query=referrer /></Set>
<Get name=refid />

<If check="{Get name=refid /}">
  <h2>Agent Spotlight</h2>

Hang on, wasn’t saving - don’t see an error but didn’t save changes due to bad nonce.

How weird, that error with “Bad nonce” on post save. I guess this happened because the post edit screen was open for longer than a day (?) and the nonce for post save action had expired.

I’ve made a note to see if there’s a solution - I suppose the nonce can be refreshed at some interval, so the post edit screen can be kept open for a longer time.

About checking URL query string with If tag - there was a recent plugin version that fixed a possibly related issue. Could you see if it works now?

<Set refid><Url query=referrer /></Set>

<If check="{Get refid}">
  Referrer: <Get refid />
<Else />
  No referrer

*edited to fix syntax typo

If you are asking whether it correctly handles when there is no query string in the URL the answer is yes. I’m able to change the logic on the page when no query strings are passed in the URL.

I copied this answer and struggled with it until I realized the right bracket is actually a )

1 Like