Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_page_uri [ WordPress Function ]

get_page_uri ( $page )
Parameters:
  • (mixed) $page Page object or page ID.
Returns:
  • (string) Page URI.
Defined at:



Builds URI for a page.

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

Source


<?php
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;
}
?>

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

User discussions [ wordpress.org ]

0 User Note(s)

None yet. Be the first!

Add New ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics