WordPress.org

Forums

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

  1. Elan42.com
    Member
    Posted 7 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
    Member
    Posted 7 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
    Member
    Posted 7 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
    Member
    Posted 7 years ago #

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

    WP_Query

  5. Elan42.com
    Member
    Posted 7 years ago #

    Thank you ;)

    Perfect.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.