• I’m a bit confused about this and I’ve not been able to find a definitive answer.

    What is the best practice in regards to front end URL variables?

    Can I grab using $_GET or should I be adding variables to WordPress with add_query_var and retrieving with get_query_var?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    If it’s going to be used in a posts query, make it a query var. I can’t think of a valid reason not to. If nothing else, it’s consistent with how WP itself works. In other situations, there may be little choice but to use one of the PHP super globals. When you do, the data may be slashed, and you must take all the necessary steps to validate and sanitize the passed values.

Viewing 1 replies (of 1 total)
  • The topic ‘get_query_var or $_GET’ is closed to new replies.