What's the best way to check current url for endpoint in a template file? I have a plugin that creates endpoints in author.php... so now i'm trying to check in author.php so that only certain code is executed if the URL ends in a specific endpoint?



The idea is that each endpoint has different content.

Thank you!

1 Answer 1


Check out this tutorial for query variables: http://www.rlmseo.com/blog/passing-get-query-string-parameters-in-wordpress-url/.

Essentially what you will be adding is a custom query variable with value either A or B to show different content. I.e. /author/username/contentA is actually index.php?author=username&customqueryvar=contentA.

  • Looks promising, i'm currently using this code: gist.github.com/705545 Any idea if there is anything in there that I can call in my template? The example you linked to uses "query_vars" to set custom variable, but i don't see that here. Mar 25, 2011 at 0:17
  • Ah no - different solution, I've never seen that one before - query var is pretty straightforward, but it depends what you need to do. If it is just the A/B and you can't get the other working give it a go.
    – Chris
    Mar 28, 2011 at 10:43
  • Or use get_query_var( 'endpoint', false ) !== false Jun 10, 2016 at 7:00

Your Answer

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

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