---
title: How to Rename Files by Custom Field or Taxonomy
description: "Rename WordPress uploads using a post's custom field values or taxonomy terms in the filename. A Pro feature."
url: "https://wpfactory.com/docs/rename-files-by-custom-field-or-taxonomy/"
updated: "2026-09-27"
category: Pro Features
---

# How to Rename Files by Custom Field or Taxonomy

[Rename Media Files: Improve Your WordPress SEO](https://wpfactory.com/item/file-renaming-on-upload-wordpress-plugin/) Pro lets you build filenames from a post's custom field values or its taxonomy terms. This is useful when your naming convention depends on structured data, such as a product attribute stored in a meta field or the category a post belongs to. Both rules live on the **General Settings** tab under **WPFactory > File Renaming** and are on by default.

### Custom field rule

The **Custom field rule** option (`custom_field_rule`) enables the `{cf:fieldname}` token. Replace `fieldname` with the meta key of the custom field you want to read from the attached post. For example, `{cf:_myfield}` inserts the value of the `_myfield` meta key.

### Taxonomy rule

The **Taxonomy rule** option (`taxonomy_rule`) enables the `{tax:taxonomy-slug}` token. Replace `taxonomy-slug` with the slug of the taxonomy whose terms you want to insert. For example, `{tax:category}` inserts the post's category terms.

### Options

| Label | Option ID | Token | Default | Free/Pro |
| --- | --- | --- | --- | --- |
| Custom field rule | `custom_field_rule` | `{cf:fieldname}` | On | Pro |
| Taxonomy rule | `taxonomy_rule` | `{tax:taxonomy-slug}` | On | Pro |

### Placing the tokens in your Filename structure

With the rules enabled, add the tokens to the **Filename structure** field (`filename_structure`) on the General Settings tab, alongside any other tokens you use. For example:

```
{siteurl}{tax:category}{cf:_myfield}{filename}
```

Each token is replaced with the corresponding value from the post the file is attached to when the file is renamed.

### Ready to set this up?

This is a Pro feature of [Rename Media Files](https://wpfactory.com/item/file-renaming-on-upload-wordpress-plugin/). If you are still on the free version, upgrading unlocks this along with the rest of the Pro toolkit. [Get Rename Media Files Pro](https://wpfactory.com/item/file-renaming-on-upload-wordpress-plugin/).

Related articles

- [How to Bulk Rename Existing Media Files](https://wpfactory.com/docs/bulk-rename-existing-media-files/)
- [Rename Media Files on Upload: Free vs Pro Versions Compared](https://wpfactory.com/docs/pro-vs-free-rename/)
- [Rename Media Files on Upload: General Settings](https://wpfactory.com/docs/general-settings/)
- [How to Create a Custom File Renaming Rule](https://wpfactory.com/docs/create-custom-file-renaming-rule/)
- [Rename Media Files Slows Down Admin / Triggers Slow Queries](https://wpfactory.com/docs/rename-media-slow-admin/)
