Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raazon/e19b929852536a0b637d448bde8601d5 to your computer and use it in GitHub Desktop.
Save raazon/e19b929852536a0b637d448bde8601d5 to your computer and use it in GitHub Desktop.
Get current url including query string in wordpress
/**
* Get current page url with query string
* @since 1.0.0
* @return: full url of your current page with query string
* @use: echo get_current_page_url();
*/
if ( ! function_exists( 'get_current_page_url_with_query_string' ) ) {
function get_current_page_url_with_query_string() {
global $wp;
return add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $wp->request ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment