WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
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. – Pwn Mar 25 '11 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 '11 at 10:43
Or use get_query_var( 'endpoint', false ) !== false – Alexander R. Torrijos Jun 10 at 7:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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