Created
October 2, 2018 18:55
-
-
Save BeFiveINFO/c27f64e92babcc46b5ba24d67abc7e48 to your computer and use it in GitHub Desktop.
[WordPress] Get all the page url in WP multisite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// throw the following into functions.php of a theme etc. | |
$site_ids = array(1,2,3); // site ids | |
foreach($site_ids as $bid){ | |
switch_to_blog( $bid ); | |
$pages = get_pages(array('post_type' => 'page')); | |
$current_site_home = get_site_url().'/'; | |
foreach ( $pages as $page ) { | |
$temp_url= get_page_link( $page->ID ); | |
if($current_site_home !== $temp_url){ | |
echo $temp_url."\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment