BEAR - WooCommerce Bulk Editor and Products Manager Professional

WooCommerce bulk edit product titles: replace, remove, change case

Product titles go wrong in batches: a size written into hundreds of names that has now changed, a supplier's code at the end of every title, a whole import in capital letters. WooCommerce bulk edit product titles work in BEAR is done in the Bulk Edit tab with the title row, for every product of a filter or for the products you tick. Below are the title jobs that come up most often and exactly how the title row handles each of them: replacing and removing words, changing case, removing the SKU, adding data to the name, and fixing the slugs that do not follow a renamed title.

How the title row works

The title row sits in the text group of the Bulk Edit tab, next to description, short description, product slug and SKU. Tick it, type into its input and choose one of four behaviours: append adds your text after the title, prepend before it, new replaces the whole title, and replace finds a piece of text inside the title and puts something else in its place. The variable list next to the input inserts placeholders that are filled in separately for each product. These mechanics are shared with the description, which bulk editing product descriptions covers in detail; this page is about what matters for titles.

The operation runs on the products the editor currently holds: the result of the Filters tab across all its pages, or only the ticked products when some are ticked. Ticked products take priority over the filter. Try every new operation on two or three ticked products first.

Find and replace a word in product titles

  1. Narrow the products down in the Filters tab. The Product title ... filter accepts a phrase with the behaviours LIKE (contains), EXACT, NOT, BEGIN and END, so LIKE with (35x35) leaves only the titles that contain it.
  2. In the Bulk Edit tab tick the title row and set its behaviour to replace. A second input, replace to text, appears with a same case / ignore case switch.
  3. Type what to find into the first input and what to put instead into replace to text: (35x35) and (30x30), or Adult and Minor. Removing the old word and adding the new one is one operation.
  4. Run it, then check a few titles in the table.

The search is plain text, not a pattern. It matches the characters exactly as typed, anywhere in the title, including inside longer words: replacing Pro also changes Product and Protein. Include the neighbouring space, Pro, or punctuation to make the match specific. same case matches only the capitalisation you typed, ignore case any capitalisation. There are no wildcards, so "remove the last word, whatever it is" cannot be expressed; group the titles by what they have in common with the END or BEGIN filter and run one replace per group.

Remove a word from product titles

To remove a word, run the same replace with replace to text left empty. Search for the word together with one of its spaces, for example Sale, so the title does not keep a double space. WordPress trims spaces at the start and end of a title when it is saved, but not inside it. If double spaces are left anyway, run a second replace with two spaces in the first input and one space in replace to text.

Change the case of product titles

The variable list has four string functions that take the current title of each product and change its case. Use one of them alone in the title input with the behaviour new:

VariableResult for "blue COTTON t-shirt"
{DO_STRING_DOWN}blue cotton t-shirt
{DO_STRING_UP}BLUE COTTON T-SHIRT
{DO_STRING_UP_FIRST}Blue COTTON t-shirt (only the first letter changes)
{DO_STRING_TITLE}Blue Cotton T-Shirt

{DO_STRING_TITLE} capitalises every word and lowers all other letters, so abbreviations and brand spellings change too: USB becomes Usb, iPhone becomes Iphone. Run it on a filter that leaves such titles out, or fix them afterwards with a replace. The functions work with any alphabet, accented and Cyrillic letters included.

To apply a rule to every title saved from the bulk editor, use the woobe_before_update_product_field filter, which receives each new value before it is written. The key of the title is post_title; older snippets that check for title never match. This example collapses repeated spaces in every title BEAR saves:

/*
 * BEAR: clean every product title saved from the bulk editor.
 * Child theme functions.php or a code snippets plugin.
 */
add_filter( 'woobe_before_update_product_field', function ( $value, $product_id, $field_key ) {
    if ( 'post_title' === $field_key && is_string( $value ) ) {
        $value = trim( preg_replace( '/\s{2,}/u', ' ', $value ) );
    }
    return $value;
}, 10, 3 );

Replace the line inside the condition with $value = mb_strtolower( $value ); to force lowercase titles, or with your own rule. More filters of this kind are listed in more settings (implicit).

Remove the SKU from titles, or add product data to them

Variables are filled in inside the search text of a replace too, separately for each product. To remove each product's own SKU from its title, use the behaviour replace, put {SKU} into the first input and leave replace to text empty. The Filters tab cannot do the same comparison: a filter value is taken literally, so a title filter with a variable in it finds nothing.

Be careful with separators. If the SKU sits in the title as Hoodie - HD-102, the search - {SKU} removes it cleanly, but for a product without a SKU the same search becomes just - and removes every dash with spaces from that title. Before such a run, add the SKU filter with the behaviour Empty to your filter: if it finds nothing, every product has a SKU and the separator is safe; otherwise search for {SKU} alone.

The same placeholders add data to titles. With the behaviour append and the text - {attribute:pa_brand}, each title gets the product's brand attribute; {SKU}, {product_cat} (the category names), {tags} and {meta:your_meta_key} work the same way. A product with no value gets an empty placeholder, so filter out such products first or the separator stays alone at the end of their titles. Put at most one {meta:...} or {attribute:...} placeholder into one operation, and do not combine it with {tags} or {product_cat}: with two of them in the same text the placeholder is read wrongly and removed. Run a second operation for the second value.

Slugs of renamed and copied products

Changing a title does not change the product's slug, the last part of its URL. That is usually what you want, because the old links keep working. It becomes a problem with copies: a product duplicated and then renamed still carries a slug made from the original title, and fifty renamed copies are fifty wrong URLs.

  • Regenerate from the title. Tick the product slug row, leave its input empty and choose new. For published products WordPress builds a new slug from the current title and adds -2, -3 when a slug is already taken. Draft products get their slug when they are published.
  • Write it from a variable. Put {TITLE}, or {TITLE}-{SKU}, into the product slug row with new; WordPress turns the text into a valid slug. The FAQ copying the title into the slug shows the same.

When the slug of a published product changes, WordPress remembers the old one and redirects visitors who arrive by the old URL. A short check of a few product URLs after the run is still worthwhile. The product slug row is not part of bulk editing in the free version; see what the free version can edit.

Variation titles

WooCommerce builds the title of a variation from the parent's title and the variation's attribute values, so variations are renamed through their parent: change the parent titles and the variations follow. While the variations switch of the editor is on, the title row is hidden in the Bulk Edit tab; switch variations off to rename the parents. Why some variation titles show the attributes and others do not is explained in variation titles with attributes.

Check the result and undo

  • Run new operations on a few ticked products first, then on the full filter.
  • Look for double spaces, separators left alone and words matched inside longer words.
  • If the result is wrong, revert the operation in the History tab: it keeps the previous title of every product in the run. The free version keeps only the last two operations, so revert before running more.

If a title operation does not behave as described, ask on the BEAR support forum with an example title before and after and the exact text you entered.