I have a really strange problem. I am trying to get the page id so that I can make a current css tag within a widget.
As a test, I was using this code to display the path:
$url_endpoint = get_permalink($post->ID);
$url_endpoint = parse_url( $url_endpoint );
$url_endpoint = $url_endpoint['path'];
and comparing it to:
They don't match! For some reason within the widget, the wrong page is being reported, ie the first code gives me back:
and the second (correctly) reports that we are on: