admin_url

Home » Functions » admin_url

The admin_url() function in WordPress is a built-in function that returns the URL to the WordPress admin area. This function can be useful when you need to link to the WordPress admin area from within a plugin or theme.

The admin_url() function takes an optional parameter that specifies the path to a specific file or page within the admin area. This allows you to link directly to a specific page or file within the WordPress admin area.

Here is an example usage code of the admin_url() function:

<a href="<?php echo admin_url( 'edit.php' ); ?>">Edit Posts</a>

In this example, the admin_url() function is used to create a link to the "Edit Posts" page in the WordPress admin area. The resulting HTML link will look like this:

<a href="http://example.com/wp-admin/edit.php">Edit Posts</a>

Note that the admin_url() function returns the URL to the admin area based on the site’s URL, so it will work correctly regardless of where WordPress is installed.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.