wp-includes/link-template.php:3573Get the URL of the WordPress admin area with admin_url(), optionally appending a path such as 'options-general.php' with the correct scheme. The default 'admin' scheme honors force_ssl_admin() and is_ssl(), so links keep working when the dashboard is forced to https.
Retrieves the URL to the admin area for the current site.
$pathstringoptional''$schemestringoptional'admin'stringEvery example is editable and runs in a real WordPress booted in your browser by WordPress Playground. Press Run, then edit the code: clicking away re-runs it. Nothing is sent anywhere until you do.
Build dashboard links from admin_url() plus add_query_arg() instead of hard-coding /wp-admin/, which breaks on subdirectory installs.
$settings_url = add_query_arg(
array( 'page' => 'myplugin' ),
admin_url( 'options-general.php' )
);
printf(
'<a href="%s">%s</a>',
esc_url( $settings_url ),
esc_html__( 'Plugin settings', 'myplugin' )
);admin_url() always targets the current site. On multisite, use network_admin_url() for network admin pages or get_admin_url( $blog_id ) to link into another site's dashboard.
function admin_url( $path = '', $scheme = 'admin' ) { return get_admin_url( null, $path, $scheme );}Introduced in 2.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/link-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.