What is the WordPress query var system and how do you add custom query vars without breaking WordPress rewrite rules?

WordPress Fundamental Hard

WordPress Fundamental — Hard

What is the WordPress query var system and how do you add custom query vars without breaking WordPress rewrite rules?

Key points

  • WordPress maintains an allowlist of recognized query vars
  • Custom query vars should be added using the query_vars filter
  • Access custom query vars using get_query_var()
  • Flush rewrite rules on plugin activation/deactivation
  • Avoid directly modifying .htaccess for custom query vars

Ready to go further?

Related questions