get_page_uri()
Gets the path (URL without the domain) to the specified permanent page. It collects the slugs of the current and all parent pages and combines them with a slash /.
If the page has parent pages, they will be added to the path via a slash /: roditel/page_name.
When you need to get the URL of a permanent page, the function get_permalink() is almost always used. It also works with caching, which means it's faster...
Uses: get_post()
1 time — 0.000237 sec (fast) | 50000 times — 3.85 sec (fast)
Hooks from the function
Returns
String|false. URI of the page, false - in case of an error.
Usage
get_page_uri( $page );
- $page(WP_Post/object/integer)
- ID or object of the page whose URI you want to get. Since version 4.6, this parameter has become optional.
Default: 0 (current post)
Examples
#1 Get the path to the current page
Suppose we have a page 1544 with label mypage and it is a child of parent. Then:
echo get_page_uri( 1544 ); // return: parent/mypage
Changelog
| Since 1.5.0 | Introduced. |
| Since 4.6.0 | The $page parameter was made optional. |