Skip to content

Instantly share code, notes, and snippets.

@BeFiveINFO
Created October 2, 2018 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BeFiveINFO/c27f64e92babcc46b5ba24d67abc7e48 to your computer and use it in GitHub Desktop.
Save BeFiveINFO/c27f64e92babcc46b5ba24d67abc7e48 to your computer and use it in GitHub Desktop.
[WordPress] Get all the page url in WP multisite
<?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