How to Change the Default Search URL Slug in WordPress

Search functionality plays a crucial role in WordPress websites, allowing visitors to easily find the content they are looking for. By default, WordPress uses a standard URL slug for search results, but you may want to customize it to align with your site’s branding or improve SEO.

In this blog post, we will explore two methods to change the default search URL slug in WordPress and provide step-by-step instructions for each. We will also discuss which method is more reliable.

Let’s start!

2 Ways to Change the Default Search URL Slug in WordPress

There are 2 simple ways that can help us to change the default search slug in WordPress. Let’s discuss them one by one.

1: Using a Plugin

Using a plugin is often the easiest and most user-friendly way to modify the search URL slug. Follow these steps to accomplish this:

  1. Log in to your WordPress admin dashboard.
  2. Navigate to “Plugins” and click on “Add New.”
  3. In the search bar, enter “Search Permalink” and hit Enter.
  4. Locate the “Search Permalink” plugin in the search results and click on “Install Now.”
  5. Once the installation is complete, click on “Activate” to activate the plugin.
  6. Go to “Settings” and click on “Search Permalink.”
  7. In the “Search Permalink” settings, you will find options to customize the search URL slug.
  8. Modify the slug according to your preference, ensuring it is relevant and SEO-friendly.
  9. Save the changes, and the search URL slug will be updated to the one you specified.

2. Using Code Snippet

File For those comfortable with code, manually editing the “functions.php” file offers more control and flexibility. Follow these steps to implement this method:

  1. Access your WordPress files either through FTP or using a file manager in your hosting control panel.
  2. Locate the currently active theme folder under the “wp-content/themes” directory.
  3. Inside the theme folder, find and open the “functions.php” file using a text editor.
  4. Add the following code at the end of the “functions.php” file:
function change_search_url() {
    if (is_search() && !empty($_GET['s'])) {
        wp_redirect(home_url("/search/") . urlencode(get_query_var('s')));
add_action('template_redirect', 'change_search_url');
  1. Save the changes and upload the modified “functions.php” file back to your server.
  2. Now, when you visit the search page on your WordPress site, the URL slug should be updated to the one you specified.

Comparing the Methods

Both methods have their advantages and considerations. Using a plugin is generally more beginner-friendly, as it offers a user interface and does not require coding knowledge. It also allows for quick modifications and easy updates.

On the other hand, manually editing the “functions.php” file provides more control and is suitable for advanced users or those with specific customization requirements.

Before implementing any changes, it’s essential to create a backup of your “functions.php” file or your entire WordPress site. This precautionary step ensures that you can easily revert back to the original setup if any issues arise.


Customizing the default search URL slug in WordPress can enhance your website’s branding, improve SEO, and provide a more user-friendly experience.

In this blog post, we explored two methods: using a plugin and manually editing the “functions.php” file. Whether you prefer the simplicity of a plugin or the flexibility of manual editing, you now have the tools to change the search URL slug to suit your needs.

Remember to choose the method that aligns with your technical proficiency and always exercise caution when modifying core files. Enjoy customizing your search URL slug and optimizing your WordPress website!