get_subdirectory_reserved_names()

Retrieves a list of reserved site on a sub-directory Multisite installation.


Description Description


Return Return

(array) $names Array of reserved subdirectory names.


Top ↑

Source Source

File: wp-includes/ms-functions.php

function get_subdirectory_reserved_names() {
	$names = array(
		'page', 'comments', 'blog', 'files', 'feed', 'wp-admin',
		'wp-content', 'wp-includes', 'wp-json', 'embed'
	);

	/**
	 * Filters reserved site names on a sub-directory Multisite installation.
	 *
	 * @since 3.0.0
	 * @since 4.4.0 'wp-admin', 'wp-content', 'wp-includes', 'wp-json', and 'embed' were added
	 *              to the reserved names list.
	 *
	 * @param array $subdirectory_reserved_names Array of reserved names.
	 */
	return apply_filters( 'subdirectory_reserved_names', $names );
}

Top ↑

Changelog Changelog

Changelog
Version Description
4.4.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note content

    Here is better solution to modify this list of reserved names. Solution by daniyalahmedk not working for 2 reasons:

    1. The function not returning anything. There is no return state in the function and WordPress get null as result of this function (not array with words).
    2. Function not accepting args. This means all other plugins/code changes will be replaced.
    /**
     * Modify reserved names for sites.
     *
     * @param $names array List of reserved names for sites.
     *
     * @return array Updated list of reserved names for sites.
     */
    function change_subdirectory_reserved_names( $names ) {
    	$position = array_search( 'blog', $names );
    
    	if( $position ) {
    		unset( $names[$position] );
    	}
    
    	return $names;
    }
    add_filter( 'subdirectory_reserved_names', 'change_subdirectory_reserved_names' );
    

You must log in before being able to contribute a note or feedback.