0

Using this:

echo add_query_arg( 'hello', '$var', get_permalink(9) );

On the following page (permalink(9)), when I

echo $_GET['hello'];

I get $var, not the contents of the variable.

Is there a way to make sure it's a string before I add it to add_query_arg?

Thanks!

1 Answer 1

1

Because you're passing it in using single quotes, which will not parse the variable. It's sending in a string "$var" instead of the actual variable.

Use no quotes and try again.

To check if it's a string, use is_string() to return a T/F value, and if true, execute.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.