wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



get_page_uri › WordPress Function

Da1.5.0
Deprecaton/a
get_page_uri ( $page = 0 )
Parametri:
  • (WP_Post|object|int) $page Optional. Page ID or WP_Post object. Default is global $post.
    Richiesto: No
    Default:
Ritorna:
  • (string|false) Page URI, false on error.
Definito a:
Codex:
ChangeLog:
  • 4.6.0

Builds the URI path for a page.

Sub pages will be in the "directory" under the parent page post name.


Sorgenti

function get_page_uri( $page = 0 ) {
	if ( ! $page instanceof WP_Post ) {
		$page = get_post( $page );
	}

	if ( ! $page ) {
		return false;
	}

	$uri = $page->post_name;

	foreach ( $page->ancestors as $parent ) {
		$parent = get_post( $parent );
		if ( $parent && $parent->post_name ) {
			$uri = $parent->post_name . '/' . $uri;
		}
	}

	/**
	 * Filters the URI for a page.
	 *
	 * @since 4.4.0
	 *
	 * @param string  $uri  Page URI.
	 * @param WP_Post $page Page object.
	 */
	return apply_filters( 'get_page_uri', $uri, $page );
}