WordPress.org

Ready to get started?Download WordPress

Forums

Developing a plugin: how to get the current page (2 posts)

  1. Elan42.com
    Member
    Posted 5 years ago #

    Hi guys.

    How do I get in php code the current page in wich I am (with complete permalink structure with slugs and so on) ?

  2. Chris Jean
    Member
    Posted 5 years ago #

    You can always use the $_SERVER['REQUEST_URI']. This of course will have any url-encoded query strings tagged on it as well, but you can quickly get rid of that with an explode. For example:

    $page = array_shift( explode( '?', $_SERVER['REQUEST_URI'] ) );

    If you still want the query string, simply use $_SERVER['REQUEST_URI'] as is.

    Will that work for you?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.