The formulas tool is very useful for editing a lot of posts at once.
We have 2 formulas: REPLACE and MATH.
The syntaxis is the following (quotes required):
=REPLACE(""Replace this"", ""with this"")
=MATH("4 + 3 – $current_value$")
As you can see in the math formula, we can use placeholders for variable information. We have the following placeholders available:
- $current_value$ = the current value of the field
- $random_number$ = a random number
- $random_letters$ = random letters
- $current_timestamp$ = current timestamp
- $current_time_friendly$ = current time using the format set in WordPress general options.
- $current_date$ = Current date in the format: d-m-Y
- $column_key$ = Other field of the same post. Change “column_key” for the actual column key. For example. $title$ , $content$ , $status$ , $my_custom_field$ .
=REPLACE(""bad word"", ""good word"")
Replace one word or phrase with another.
=REPLACE(""$current_value$"", ""$current_value<br/>Thank you for reading my post!"")
Add a message at the end of the post. It can be plain text or html.
=REPLACE(""$current_value$"", ""Welcome to my site!<br/>$current_value$"")
Add a message at the beginning of the post. It can be plain text or html.
=REPLACE(""<img"", ""Do you like the image below? Share it!<br/><img"")
Add a message above the post images asking the user to share the image. It can be plain text or html.
=MATH("$current_value$ + 10")
Increase the products prices by $ 10.
=MATH("$current_value$ * 1.1 "")
Increase the products prices by 10%.
=MATH("$current_value$ + ( 0.234343898 * 0.1) – 29 / 28 "")
A complex math operation.
Applying the formula to the sale price field, you can copy the value of regular price to sale price field.
=REPLACE(""$current_value$"", ""Posts published by $author$ on $date$"")
Applying the formula to the “category” field, you can create categories combining other fields.
This is for advanced users. The replace formula accepts regular expressions (regex). You just need to prepend the “search” value with [::regex::]
Please test your regular expressions before executing them, you can use this online tool.
- The math formula must be used only on numeric columns. For example, products prices. If you use it on text fields, like post titles, you will get errors because it will try to convert the text to a number.
- The replace formula accepts HTML but only safe/simple tags and attributes like links, paragraphs, images. For example, script tags will be removed.
- If you use a text that contains html with the “style” attribute, the replace formula might remove the last semicolon from the css, making the search term not match.
- If you use a text that contains html with attributes using a single quote, i.e. class=’test’, the replace formula might remove the attribute. Use double quotes to avoid this.
- The “formulas” tool is very powerful and it must be used carefully. You MUST backup your database before executing formulas, if you enter the wrong formula you can mess up your posts data. Use it at your OWN RISK. We are not responsible for any data loss or disruption in your business caused by this plugin.
- The “formulas” tool allows you to select the group of posts to apply the formula to. You can execute the formula on all posts or select a specific tag or category. You can test your formula by creating a new post and add it to a new tag/category, then execute the formula on the specific tag/category.