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

I have noticed that in some instances in WordPress (such as in my custom post types), GET variables appear as following in the URL:


However, in other instances (such as when I am pointing to my login 'virtual' page which I created using the rewrite API), the urls look like this:


As you can see, there is a forward slash before the first variable. What is causing this? Which one is the normal way for them to appear? Is there any functional difference? And finally, assuming that it makes sense, how can I make them both behave in a similar manner?

  • William


add_action( 'init', 'add_virtual_page_template' );
function add_virtual_page_template()
    global $wp, $wp_rewrite;

    $wp->add_query_var( 'template' );

    add_rewrite_endpoint( 'login', EP_PERMALINK | EP_PAGES );
    add_rewrite_rule( 'login/?', 'index.php?template=login', 'top' );


add_action( 'template_redirect', 'add_virtual_page_redirect' );

function add_virtual_page_redirect()
    global $wp;

    $queryvar = get_query_var('template');

    if ($queryvar && $queryvar == 'login')
share|improve this question

There is no "normal" way (either is commonplace), but it all comes down to your permalink structure, and whether that has a trailing slash or not.

As for your login page, it all depends on how you're generating the URLs, but I would suggest using user_trailingslashit( $basepath_without_query ).

As the name suggests, it will apply (or remove) trailing slashes to match the configured permalink structure.

share|improve this answer
Hey - I have included that snippet that I use to generate the URL - how would I implement your solution? – William Jun 25 '13 at 17:04

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.