Add Custom Fields to WordPress Permalinks

For better-organized and more relevant WordPress permalinks, adding custom fields can be a good option. While this can be done using tailored code, it requires a deep understanding of how WordPress handles permalinks, which might not be intuitive for those without coding experience.

Permalink Manager Pro simplifies this process, allowing you to easily add custom data to your URLs without needing any coding skills. This makes it perfect for improving the permalinks of WooCommerce products, custom post types, taxonomies, or any other content types you work with.

It offers a range of customization options that are unmatched by any other plugin, making it easy for users to include custom fields in their permalinks with just a few simple clicks.

The features described in this article are exclusive to the Permalink Manager Pro and are not available in Permalink Manager Lite (free version).

Buy Permalink Manager Pro

Custom fields permalinks

Custom fields are a powerful tool in WordPress, but using them in your permalinks can offer even greater value. If you include custom field values like department names, locations, or specific product details in your URLs, you create more meaningful and easy-to-navigate links.

This approach not only helps visitors find relevant content quickly but also improves content organization.

The original permalinks usually only have the rewrite base that is specific to the custom post type and the slug name that is based on the title:

https://example.com/team/john-doe/

Unfortunately, WordPress does not offer a built-in solution to enhance this permalink format by inserting additional data, such as custom fields. As a result, your options are limited to a third-party plugin or implementing a custom solution with rewrite rules.

Imagine you need to update your URL structure to show both the department and location for each employee. One way to do this is by adding a new hierarchical taxonomy and attaching its multi-level slug to each employee’s individual page.

If you prefer a simpler solution, you can use Permalink Manager Pro to replace custom field tags with the actual values from those fields automatically:

https://example.com/team/%__country%/%__city%/%__department%/john-doe/
https://example.com/team/norway/oslo/management/john-doe/

The custom field/meta keys values may be appended to the custom permalinks of posts, pages, custom post types items (eg. WooCommerce products), categories, post tags, and custom taxonomies (eg. product categories).

Supported Plugins

Advanced Custom Fields

The plugin allows you to add custom fields managed by Advanced Custom Fields to custom permalinks.

Inside the permalinks, you may include any of the following field types: "Text", "Number", "Relationship", "Taxonomy", "Select", "Post object", or "Date picker".

WooCommerce

Permalink Manager is also unquestionably the best option in one specific case. The plugin may be used to incorporate the SKU number in WooCommerce's product permalinks. A more comprehensive instruction may be found in this article.

Other plugins

Permalink Manager is compatible with nearly all custom fields plugins. It can be used to modify the permalink structure of custom post types and taxonomies that have been registered using the plugins including:

  • Pods
  • Toolset
  • JetEngine
  • Custom Post Type UI
  • Metabox.io
  • Voxel

In general, Permalink Manager Pro can be integrated with other plugins and themes using custom fields as long as they use the built-in custom field mechanism. If this is the case, you may use the meta field name as a Permastructure tag, as described below in the "Native/generic custom fields" section.

Step-by-Step Guide

The custom field permastructure tags should be structured as follows: %__custom_field_key%.

Find the Custom Field Meta Key

Permalink Manager has "out-of-the-box" support for custom fields created by some of the most popular third-party plugins. It may also be used to insert custom fields that are controlled by the native "Custom Fields" metabox or code snippets from third parties (eg. from The Meta Box Generator)

Native/generic custom fields & other plugins and themes

How to display Custom Fields container in WordPress admin panel?

You can use the native custom fields if you don't want to install any additional plugins (such as Advanced Custom Fields). Enable the "Custom Fields" metabox in the "Screen Options" admin panel to identify their names.

The custom fields table in WordPress editor.
The custom fields table will be shown somewhere below the main content editor once you enable the "Custom Fields" metabox.

The permastructure tags (displayed in “Name” column) are as follows:

  • country for “Country”, ergo permastructure tag should be: %__country%
  • city for “City”, ergo permastructure tag should be: %__city%
  • department for “Department”, ergo permastructure tag should be: %__department%

MetaBox.io

The MetaBox plugin allows you to create custom fields in numerous ways. Using the same procedure as for "native/generic custom fields" is the simplest way to determine the names of custom fields.

Advanced Custom Fields

If you have used the "Advanced Custom Fields" plugin to create your custom fields, the procedure is slightly different. Below are some examples of metaboxes with fields managed by the ACF plugin.

A sample WordPress permalink with custom field values.
The new permalink contains the custom fields values set-up with Advanced Custom fields.

To retrieve the custom field names, navigate to ACF's dashboard and choose the "Custom Fields" menu section in the admin sidebar navigation. Then, under the table labeled "Field Groups" select the group in which you specified your custom fields.

Following that, you should see the "Edit Field Group" page, which has the whole list of custom fields. Their names are displayed in the "Name" column.

Advanced Custom Fields names to be used in WordPress permalinks

Similarly, the meta keys (custom fields’ names) are in this case as follows:

  • country for “Country”, ergo permastructure tag should be: %__country%
  • city for “City”, ergo permastructure tag should be: %__city%
  • department for “Department”, ergo permastructure tag should be: %__department%
A list of ACF custom fields that can be appended to permalinks
  • Text field
  • Number field
  • Relationship field
  • Taxonomy field
  • Select field
  • Post object field
  • Date picker field
Permalink Manager will replace the "Relationship", "Post Object", or "Taxonomy" field in a permastructure tag with the slug of the specified post/term item if you use it in a permastructure tag.

Toolset Types

As with the ACF plugin, you can quickly add custom fields specified using the "Toolset Types" plugin to WordPress permalinks. The Toolset Types-controlled metabox should be presented directly below the main text editor.

Toolset Types custom fields in WordPress permalinks
Toolset Types custom fields in WordPress permalinks.

Click on the "Toolset" menu option in the left admin menu, then navigate to the "Post Fields" section to access the Toolset custom field names. The list containing "Post Field Groups" should now be visible. Click on the one where you specified which custom fields should be included in WordPress permalinks.

Post Field Groups in Toolset

After opening the field settings, you must click on each field to see its slug. Please copy the slug if you want to use it in permastructure settings.

Sample Toolset Types custom field that can be used in WordPress permalinks

There is just one custom field slug shown above. With Permalink Manager, you can, of course, add multiple custom fields to WordPress permalinks.

The permastructure tags should look like this.

  • country for “Country”, ergo permastructure tag should be: %__country%
  • city for “City”, ergo permastructure tag should be: %__city%
  • department for “Department”, ergo permastructure tag should be: %__department%

JetEngine

Custom fields handled by the JetEngine plugin are likewise supported by Permalink Manager Pro. To add the custom field to the permalink, you must first identify its name. It should be rather simple, given the names are displayed immediately in the metaboxes underneath the field labels:

Where you can find the custom fields' names in JetEngine?

In this example, the permastructure tag will be: %__country% (%__name_of_the_field%).

Voxel

You can find the field name in either the list of all custom fields or the "Field options" section, as demonstrated in the screenshots below.

Custom fields list
The field key "customer" is displayed next to the field name and type.
Single field
You can also find the field key directly in "Field options" panel.

After you've found and validated the names of the meta keys, you can use them as tags inside the permastructures for the "Team" custom post type. To adjust the Permalink Manager permastructure settings, go to the Permalink Manager dashboard ("Tools -> Permalink Manager -> Permastructures").

Wordpress permalink structure settings with custom field values.
Permastructure settings for “Team” custom post type.

Apply Changes to Existing URLs

By default, custom fields will only be added to the new posts or terms permalinks.

If you want to add custom field values to previously existing WordPress URLs, you must regenerate them using the "Regenerate/reset" tool. To locate it, go to the "Tools -> Permalink Manager -> Tools" section. Please see this page for detailed instructions on how to use it.

Extra Tips

In general, Permalink Manager will use the default URI (with custom field values included) as a custom permalink once you create a new post with certain custom fields values.

Auto-update "Current URI" field in URI Editor

Keep in mind that if you want the actual permalink to update automatically when you save or edit the article and change the custom field value, you will need to select "Auto-update the URI" option. You may enable it individually for each post or configure it globally for all posts. More information on how to activate this feature may be found here.

Obviously, you may override the default URI format by manually changing the permalinks of certain posts.

A sample WordPress permalink with custom fields manually adjusted.

Posted on , updated on by Maciej Bis

About author

Maciej has been working with WordPress for more than 10 years and is the developer of Permalink Manager, a popular plugin for managing permalinks. Throughout his career, he has collaborated with clients from various countries and has built a deep understanding of WordPress development.

Go up