Skip to content

Instantly share code, notes, and snippets.

@mrkkr
Created May 8, 2018 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrkkr/ba79be2e9b31e3f05b3297676bb80b00 to your computer and use it in GitHub Desktop.
Save mrkkr/ba79be2e9b31e3f05b3297676bb80b00 to your computer and use it in GitHub Desktop.
Wordpress - get current url by PHP #php
<?php
/// without prefix
$current_url = "//" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
/// with prefix
global $wp;
$current_url = home_url( add_query_arg( array(), $wp->request ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment