How to Add an Admin Link to All Settings in WordPress

Home » Snippets » How to Add an Admin Link to All Settings in WordPress
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

If you’re a WordPress user, you’re probably familiar with the various settings that are available for your website. However, locating all of those settings can sometimes be a bit of a chore. In this article, we’ll show you how to create an admin link that takes you to a page which lists all of your site’s settings, making it easier for you to find and adjust the options you need. This handy trick will save you time and make navigating your WordPress dashboard much simpler. Let’s dive in!

					function wpturbo_admin_link_to_settings() {
    ?>
    <div class="wpturbo-settings-link">
        <a href="<?php echo esc_url( admin_url( 'options.php' ) ); ?>"><?php _e( 'Go to all settings', 'wpturbo' ); ?></a>
    </div>
    <?php
}
add_action( 'admin_footer', 'wpturbo_admin_link_to_settings' );
				

The code snippet provided here adds a new link to the WordPress admin dashboard for navigating directly to all settings available in the options page. This saves the user the hassle of having to navigate through several menus to access all settings.

The first thing we do is create a new function called wpturbo_admin_link_to_settings(). This function will hold the HTML markup for displaying the settings link.

Inside the function, we create a div with a class name of wpturbo-settings-link to wrap the link. The class name can be changed depending on the user's preference.

The next step is to create a hyperlink using the a tag and link it to the options.php file using the admin_url() function. The admin_url() function returns the URL for the current WordPress admin area with the specified path appended to it. Here, we've added options.php as a path in the function.

<a href="<?php echo esc_url( admin_url( 'options.php' ) ); ?>">

The esc_url() is useful here because it helps to sanitize and validate the URL before outputting it on the browser.

We've also added a string of text to the hyperlink, which reads "Go to all settings". The text can be changed according to the user's preference or language.

Finally, we hook the wpturbo_admin_link_to_settings() function to the admin_footer action, which ensures that the hyperlink is displayed at the bottom of the WordPress admin dashboard on every admin page.

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