Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress Rest API - Ajout endpoint liste de tous les sites d'un multisites
<?php
function wearewp_api_custom_route_get_sites() {
$args = array(
'public' => 1, // I only want the sites marked Public
'archived' => 0,
'mature' => 0,
'spam' => 0,
'deleted' => 0,
);
$sites = get_sites( $args );
return $sites;
}
add_action('rest_api_init', function() {
register_rest_route('wp/v2', 'sites', [
'methods' => 'GET',
'callback' => 'wearewp_api_custom_route_get_sites'
]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment