View Categories

How to Rename Files by Custom Field or Taxonomy

Rename Media Files: Improve Your WordPress SEO 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. If you are still on the free version, upgrading unlocks this along with the rest of the Pro toolkit. Get Rename Media Files Pro.