Created
July 29, 2021 08:35
-
-
Save Soean/7a6e0bd68590cedb572b9f0eeca5da14 to your computer and use it in GitHub Desktop.
List all pages of 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 | |
add_action( | |
'cli_init', | |
function () { | |
\WP_CLI::add_command( 'list_pages', function () { | |
$sites = get_sites(); | |
foreach ( $sites as $site ) { | |
switch_to_blog( $site->blog_id ); | |
$query_args = [ | |
'post_type' => 'page', | |
'posts_per_page' => '-1', | |
'post_status' => 'publish', | |
]; | |
foreach ( get_posts( $query_args ) as $post ) { | |
$permalink = get_permalink( $post ); | |
//$permalink = str_replace('wptest.', 'www.', $permalink); | |
//$permalink = str_replace('.localhost.parship.dev', '', $permalink); | |
$permalink = str_replace('.localhost', '.integ-live', $permalink); | |
\WP_CLI::log( $permalink ); | |
} | |
} | |
} ); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment