Get closest page ID from URL
-
02-11-2019 - |
Question
Lets say on my WordPress website I navigate to:
www.example.com/media-centre/news/17/an-example-news-post
In this case I am looking at a post in a CPT called News
.
What I want to do is get the page ID thats closest to that URL. I know the closest page ID can be found at:
www.example.com/media-centre/news/
So how do I loop back over my URL to find the closest page and then how do I get the ID of that page?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange