Perhaps this is because I’ve got WP set up as multisite.
Yes, that’s right, WordPress disables the siteurl
(and also admin_email
) settings on a Multisite — see register_initial_settings()
for the source.
And I don’t know why they disable those (two) settings, but you can explicitly enable them like so for the url
/siteurl
setting, which for example, would go in the theme’s functions.php
file:
// I copied this from the source..
register_setting(
'general',
'siteurl',
array(
'show_in_rest' => array(
'name' => 'url',
'schema' => array(
'format' => 'uri',
),
),
'type' => 'string',
'description' => __( 'Site URL.' ),
)
);
Tried & tested working with WordPress 5.6.1 Multisite.
And also, wp.data.select( 'core' ).getSite()
uses the Settings endpoint, so it’s normal that the url
property is missing by default on a Multisite.
Apart from that, getSite()
caches the API results, so you’d need to reload the post editing screen/page in order for getSite()
to give you the correct result, i.e. with the url
property.