How to easily use custom fields inside WordPress permalinks?

The native WordPress settings and rewrite rules does not allow to fully customize the posts & categories permalinks.

Some of the functionalities presented in this post are available only in Permalink Manager Pro.
Buy the plugin here.

Although, custom fields values can be inserted to permalinks with some tailored hooks & hacks, it is still a quite complicated operation. Permalink Manager is currently the only actively supported plugin that allows to make this process considerably easier and faster.

Table of contents

    Case study

    Let’s assume that you want to add country, city and department names to our team members single pages’ permalinks to suggest where each of our employees work. Using custom taxonomies may be overkill in this case and setting this data via custom fields seems more reasonable.

    Please note that the this tutorial shows only usage example and custom post type name and/or custom fields (meta tags) may be completely different in your particular case.

    Video tutorial

    Step 1A. Find the “generic” custom fields (meta keys)

    If you are not using “Advanced Custom Fields” plugin to handle your custom fields, the meta keys should be listed in “Custom Fields” metabox that can be enabled with “Screen Options“.

    When “Custom Fields” section is activated, you will need to scroll down the page a bit. The table with meta keys should be displayed somewhere below content editor.

    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%

    Step 1B. Find the custom fields (meta keys) handled by Advanced Custom Fields

    If your custom fields are set-up with “Advanced Custom Fields” plugin, to find the custom field name, you will need to go to ACF’s dashboard (“Custom Fields” section in the side navigation) and afterwards click on “Field Group” where your custom fields are set.

    Go to Advanced Custom Fields dashboard and select Field Group with searched custom fields.

    After the Field Group name is clicked, you will be redirected to “Edit Field Group” page where a table with custom fields list should be placed.

    Meta keys will be displayed in “Field Name” column.

    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%
    Supported ACF field types:

    • Text field
    • Relationship field
    • Taxonomy field
    • Select field
    • Post object field (since 2.1.1 version)

    If “Relationship”, “Post object” or “Taxonomy” is used as a custom field tag, Permalink Manager will use the slug of selected post/term item.

    Step 2. Adjust permastructures

    After the meta keys are founded, you can insert them as tags inside the permastructures for “Team” custom post type. The settings can be altered in “Permastructures” section of the Permalink Manager’s dashboard (“Tools -> Permalink Manager -> Permastructures“).

    Permastructure settings for “Team” custom post type.
    The format of permastructure tags should be: %__custom_field_key%.
    Please note that the updated permastructure will be automatically used only to new single pages/posts permalinks. To apply the changes to the old permalinks as well, please follow the instructions in the next step.

    Step 3. Reset old permalinks

    If you would like to use the new permastructures for old permalinks, please use “Regenerate/reset” tool available in another plugin’s section (“Tools“).

    To reset the Product’s permalinks for “Team” custom post type, please use following settings:

    • Mode” to: “Custom URIs
    • Select content type” to: “Post types
    • Select post types” to: “Team
    • Select post statuses” to “Published

    After “Regenerate” button is clicked, a list of updated permalinks should be displayed in the bottom.

    Add new and edit old permalinks individually

    When the post is saved and custom fields are not empty, the default URI (with custom fields values inserted) will be available to use.

    You can auto-update the URI (then after the post is saved, default URI will be automatically recreated and used for the permalink if the custom fields’ values are changed). It is also possible to manually change the permalinks and overwrite the default URI for particular posts.


    • What if we want to use an ACF field that is not a plain text field? For example, a post object field.

      • Hi James,

        besides text fields, my plugins supports also following ACF fields:

        • Relationship field
        • Taxonomy field
        • Select field
        • Post object field (since 2.1.1 version)

        When it comes to: Relationship, Post object & Taxonomy field – if they are used as a custom field tag. My plugin will use the slug of selected post/term item.

        2.1.1 version will be released in next 1-2 weeks. If you own a valid license key, I can send you a download link, so you can download it before it is officially released.

        if you need a more complex solution, you can use this is snippet as a starter:

      Leave a Reply

      Your email address will not be published. Required fields are marked *




      This site uses Akismet to reduce spam. Learn how your comment data is processed.

      Wait!!! Before you go...

      Still not convinced? Use following discount code during Gumroad checkout and get 10% off!


      If you have any questions or need further information, please feel free to contact me via email: