0

I'm coding a custom plugin for a client and I want to use certain $_GET variables in the URL in my custom pages, such as ?s=$1, ?p=$1 and ?paged=$1. With some of these variables, such as ?paged=$1, it redirects me to another URL: [PAGE_URL]/page/$1.

Are there any filter or action hooks that I can use to remove these functionalities for particular pages?

2

You should find alternatives, as noted on the codex article of "Reserved Terms" in WordPress (emphasis mine):

There is a complete set of reserved keywords, or terms, in WordPress that should not be used in certain circumstances as they may conflict with core functionality. You should avoid using any of these terms when:

  • Passing a term through a $_GET or $_POST array
  • Registering a taxonomy or post type slug
  • Handling query variables

You could use ?search= in place of ?s= and ?pg= in place of ?page= for example.

Or, depending on what exactly you're doing, you could create a custom rewrite rule with add_rewrite_rule() and then you could name the underlying query vars whatever you wanted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.