get_page_uri

Definition:
function get_page_uri($page) {}

Builds URI for a page.
Sub pages will be in the "directory" under the parent page post name.

Parameters

  • mixed $page: Page object or page ID.

Return values

returns:Page URI.

Source code

function get_page_uri($page) {

	if ( ! is_object($page) )

		$page = get_page($page);

	$uri = $page->post_name;



	// A page cannot be it's own parent.

	if ( $page->post_parent == $page->ID )

		return $uri;



	while ($page->post_parent != 0) {

		$page = get_page($page->post_parent);

		$uri = $page->post_name . "/" . $uri;

	}



	return $uri;

}

1548

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: