---
title: "Content Transformation Functions for WordPress Import and Export"
url: "https://wpimportexport.com/content-transformation-functions-for-wordpress-import-and-export/"
description: "Clean CSV post titles on export, apply title case on import, and match drafts by slug. Follow the WordPress admin steps or run the workflow with an AI agent."
type: post
published: 2026-07-31T10:05:15+00:00
modified: 2026-11-08T11:19:57+00:00
categories: ["Video Lessons"]
tags: ["AI function generator", "content transformation functions", "Import Export by RockStarLab", "ordPress import export plugin", "WooCommerce import", "WordPress Bulk Update", "WordPress data transformation"]
docs_topics: ["Data, formats and functions"]
---

# Content Transformation Functions for WordPress Import and Export

A partner wants uppercase titles in a CSV feed, but your editors want readable titles in WordPress. With the PRO transformation functions in Import Export by RockStarLab, you can give each destination the format it needs. Apply a chain to the title column during export, then apply a different function to the title mapping during import.

| Source title | CSV for the partner | Title saved on import |
| --- | --- | --- |
| `Riverside field notes` | RIVERSIDE FIELD NOTES | Riverside Field Notes |
| `Orchard weekend guide` | ORCHARD WEEKEND GUIDE | Orchard Weekend Guide |

The two source titles have three spaces after the first word. The CSV needs one. Each post also has a slug, body and status. Carry those three fields through as supplied, so you can match each row to the same draft next time.

## Choose a function for the field

In WordPress, open **Import Export by RockStarLab → Functions → Browse Library**. Search for **Remove Multiple Spaces** and **Convert to Uppercase**. You can assign a library function directly in the export wizard. Choose **Preview** to inspect what a snippet does or **Customize** to adapt it. The [introduction to transformation functions](https://wpimportexport.com/what-are-transformation-functions-and-how-to-use-them-during-import-or-export/) covers the editor.

![WordPress function library with text and numeric transformations](https://wpimportexport.com/wp-content/uploads/2026/11/wordpress-field-transformations-01-library.webp)

_Look under String Operations for spacing and capitalization rules._

### Write a custom rule when spacing is the only change you need

Choose **New Function** and give it a name you will recognize in the mapping screen, such as _Clean field-guide title_. Enter the following body in the PHP editor. The current field arrives in `$value`.

```
return trim(preg_replace('/\s+/', ' ', (string) $value));
```

This replaces runs of whitespace with a single space and trims the ends. Capitalization stays as supplied. Enter a title with leading spaces, repeated spaces and trailing spaces in **Test Function**, then choose **Test**. Also try an empty string. Save the function when the output matches your rule. For the uppercase feed below, the two library functions are enough.

![Custom PHP function with a sample title in the WordPress function editor](https://wpimportexport.com/wp-content/uploads/2026/11/wordpress-field-transformations-02-editor.webp)

_Test the value before saving a custom whitespace rule._

## Export uppercase post titles to CSV

1. Open **Export → Blog Posts**. Use the [export filters](https://wpimportexport.com/wordpress-export-data-filters-examples-how-to-use-them-effectively/) to select your two posts. For this example choose **Slug → Contains → functions-**. Refresh the count and expect two matches.
2. In **Select Fields**, drag Title, Slug, Content and Status into the export structure. You can also add the Standard group and remove the extra columns. The [post export walkthrough](https://wpimportexport.com/wordpress-csv-posts-export/) covers field selection in detail.
3. Open **Assign transformations** on the Title column. Assign **Remove Multiple Spaces**, then **Convert to Uppercase**. The list runs from top to bottom. Enter the source title in **Test Value** and select **Test Pipeline** to inspect each step.
4. Choose **Apply Transformations**, continue to **CSV**, include the header row, give the file a name and select **Start Export**. Download the file when the export finishes.

![Title field pipeline with whitespace cleanup followed by uppercase conversion](https://wpimportexport.com/wp-content/uploads/2026/11/wordpress-field-transformations-03-export-chain.webp)

_The last step produces RIVERSIDE FIELD NOTES for the CSV title column._

Open the CSV and find the row by its slug. The title should be uppercase with single spaces. The `post_content` cell can still contain HTML such as `<strong>weekend</strong>`. Assigning the rules only to Title preserves the markup in the body. Open the source post to see its original capitalization.

## Import the CSV with readable titles

1. On the receiving site, open **Import → Blog Posts**. Upload the CSV with the header option enabled. Preview the two rows and check that the title, slug, content and status each have their own column.
2. In **Field Mapping**, click **Auto Map**. Review all four pairs, especially `post_name` → Slug and `post_title` → Title. For files with supplier-specific headings, use the [CSV field mapping guide](https://wpimportexport.com/how-to-import-csv-files-into-wordpress-with-field-mapping/).
3. Under **Mapped Fields**, open the transformation control beside the title pair. Add **Title Case**. Test `RIVERSIDE FIELD NOTES`, check for `Riverside Field Notes` and apply the transformation. Check brand names separately if their capitalization matters.
4. On the options screen, match existing items by **Slug**. Select **Update** for a match and **Create** for a new row. The sample status is `draft`. Start the import and open a resulting draft in Posts.

![WordPress import result showing two created posts and zero failures](https://wpimportexport.com/wp-content/uploads/2026/11/wordpress-field-transformations-07-import-result.webp)

_On the first import, two new slugs produce two new drafts._

![Riverside Field Notes draft in WordPress with its slug and formatted paragraph](https://wpimportexport.com/wp-content/uploads/2026/11/wordpress-field-transformations-08-post.webp)

_Check the title, the bold word in the body, the slug and draft status together._

To repeat this as an update-only job, keep the slug mapping and set **If No Match Found → Skip**. Matching on the stable slug lets the title change while WordPress keeps the same post ID. See [updating existing posts without duplicates](https://wpimportexport.com/how-to-bulk-update-existing-wordpress-posts-without-creating-duplicates/) for partial updates.

## Choose rules for prices, dates and HTML

| Category | Example Functions | Common Use Case |
| --- | --- | --- |
| String Operations | Convert to Uppercase, Title Case, Trim Whitespace, Generate Slug | Clean titles, slugs, names, and text fields |
| Date & Time | Format Date for MySQL, Convert DD/MM/YYYY, Extract Year | Normalize imported dates for WordPress or database fields |
| Numeric Operations | Clean Price, Convert to Float, Round to 2 Decimals | Prepare WooCommerce prices, numbers, discounts, and stock values |
| HTML Operations | Strip HTML Tags, Decode HTML Entities, Sanitize Text | Clean imported content from old websites, feeds, or external systems |
| WordPress Functions | Find User ID by Email, Find Term ID by Slug, Create Category if Not Exists | Convert readable values into WordPress IDs or create missing categories |
| Validation | Validate Email, Validate URL, Require Non-Empty | Check imported data before saving or exporting it |
| Advanced | Add Prefix, Add Suffix, Map Values, Extract from JSON, Split by Delimiter | Handle custom migration rules and structured data cleanup |

Decide which input format you accept before choosing a price function. For a US supplier, `$1,299.99` should become `1299.99`. For a supplier using decimal commas, `€89,50` should become `89.50`. Removing every comma would turn the latter into `8950`. Test both formats if your file mixes them, and decide how to handle blank prices separately from zero. For a catalogue matched by SKU, follow the [price and stock import guide](https://wpimportexport.com/how-to-update-woocommerce-prices-stock-by-sku-csv/).

For ambiguous dates such as `04/05/2026`, choose the snippet for the supplier’s stated day/month order. For plain-text excerpts containing encoded markup, decode HTML entities before stripping tags. Apply that chain to the excerpt only if the body should keep its links and formatting. To change fields already stored on a single site, use [Content Updater](https://wpimportexport.com/bulk-content-update-in-wordpress-with-content-updater/).

## Run the same CSV workflow with an AI agent

Connect your agent to each WordPress site using the [Abilities API setup guide](https://wpimportexport.com/how-to-use-the-wordpress-abilities-api-with-ai-agents-exports-imports-content-sync-and-backups/). Enable PRO on the sites that apply transformations. The Functions editor’s optional AI Generator drafts PHP from a description. An MCP-connected agent can select existing library functions and run jobs without generating PHP.

> On the source site, find the two draft posts with slugs functions-orchard and functions-riverside. Show me their IDs and current titles. Find Remove Multiple Spaces and Convert to Uppercase with rsl-ie-pro/function-list. Use rsl-ie-pro/function-test-pipeline to show each intermediate value for the Riverside title.

> Export only those two post IDs to a CSV with a header row. Include post_title, post_name, post_content and post_status. Apply Remove Multiple Spaces followed by Convert to Uppercase to post_title. Name the file field-guide-functions. When the job finishes, read the CSV and show me both titles beside their slugs.

For posts the agent can call `rsl-ie/export-start` with `options.selected_ids`. In `field_functions` use the field key `post_title` and the ordered IDs `snippet_remove_multiple_spaces` and `snippet_uppercase`. Read the completed job with `rsl-ie/job-get` and retrieve the CSV with `rsl-ie/file-get`.

> On the destination site, upload that CSV. Match the four columns to their corresponding post fields. Assign Title Case only to post_title. Match by post_name, update existing matches and skip missing rows for this repeat run. Report the post IDs, titles, slugs and draft status afterward.

On import, attach `function_ids: ["snippet_title_case"]` to the title mapping in `rsl-ie/import-start`. Use the destination file ID after uploading the CSV there. For a first import into an empty site, explicitly request creation of missing rows. For a repeat, compare destination IDs before and after and review the [Jobs Log](https://wpimportexport.com/how-to-use-jobs-log-and-schedule-wp-import-and-export-jobs/).

## Video walkthrough

The video shows an earlier plugin interface. Follow the screenshots above for the current field controls.

[Video: Content Transformation Functions for WordPress Import and Export](https://www.youtube.com/watch?v=6k2yHxvFtBo)

For a step-by-step find and replace in post content, with a preview before anything is written, see [Bulk Find and Replace in WordPress Posts (With a Preview First)](https://wpimportexport.com/bulk-find-replace-wordpress-posts/).

## FAQ

### What are Content Transformation Functions?

Content Transformation Functions are custom PHP functions that modify field values during import, export, or bulk content update workflows.

### Are Transformation Functions available in the free version?

No. Transformation Functions are available in the PRO version of Import Export by RockStarLab. You can activate PRO for free for your first month with no credit card required.

### Can I use AI to generate transformation functions?

Yes. If your OpenAI API key is connected, you can describe the function you need and generate PHP code with the AI Generator.

### Can I test a function before using it?

Yes. The function editor includes a testing area where you can enter a sample value and see the transformed output before using the function in a real workflow.

### Can I assign multiple functions to one field?

Yes. You can assign multiple functions to the same field. They will run one by one in the order you assign them.
