When you use a WordPress theme or plugin which incorporates with Meta Box, all the information of fields and meta boxes are fixed, such as: meta box title, number of fields, fields’ names and descriptions, … It might be better in some situations when you want to change these texts or add/remove fields to a meta box or even remove a meta box.

Assuming we have 2 meta boxes registered in a WordPress parent theme or a plugin with this code below:

which are rendered as following:

meta boxes

Now we will:

  • Remove “Personal Information” meta box
  • Change title of “Address Info” meta box to “Address”
  • Add description for field “Street” in “Address” meta box
  • Add field “zip_code” (text field) to “Address” meta box

Our custom code will be put in functions.php file of the child theme (or in a custom plugin if we want).

The principle is simple as following:

  • We hook to rwmb_meta_boxes filter with higher priority than 10 to get all registered meta boxes
  • Then we check meta boxes by ID or title to get the meta boxes we want to edit / remove
  • Remove or change meta boxes information if needed (such as meta box title)
  • For that meta box, we loop through all custom fields and change fields’ info
  • And finally add more fields to that meta box if needed

The code is quite straight as following (with all necessary comments):

Here is the result:

edit remove meta boxes

Note: It’s always a good practice to set meta box ID (even when it’s optional). In the code above we check meta boxes by ID to get the ones we want to edit or remove. It’s fine to check by meta box title, but it will be harder if the website uses another language and the meta box title is translated.