[resolved] Where I am in the site? parsing http_request (5 posts)

  1. ELAN42.com
    Posted 8 years ago #

    Hi... does someone know where wordpress parses the http_request of the client?

    I'd like to have the first "folder", for example if my website is http://www.nokao.com and a client is on http://www.nokao.com/blog/ I want the "blog" string.

    Actually to know where I am I do a very complicate if-else block with categories and pages tag-functions, but honestly I think it's a loss of server-memory...

    Otherwise, I need to know how to get the CATEGORY/MOTHER_PAGE I'm in, without using stupid recursive functions.

  2. Adam Brown
    Posted 8 years ago #

    If all you're trying to figure out is what is in the user's address bar, you don't need a WP function. PHP will do that for you. Try one of these variables. If the user visits 'http://www.example.com/blog/folder?p=3' then...

    $_SERVER["REDIRECT_URL"] == '/blog/folder';
    $_SERVER["REQUEST_URI"] == '/blog/folder?p=3';
    $_SERVER["HTTP_HOST"] == 'www.example.com';

    Take your pick.

  3. ELAN42.com
    Posted 8 years ago #

    Yes, I knew, but I suppose that WP parses that somewere...

    My intention was to not parse it again... with the risk of doing errors e/o using useless server resources.

    Is there another solution?

  4. Adam Brown
    Posted 8 years ago #

    Ahh. If I'm understanding you correctly, I think you'll find your answer here:


  5. ELAN42.com
    Posted 8 years ago #

    Thank you ;)


Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.