PHPackages                             maheshwaghmare/wp-meta-fields - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. maheshwaghmare/wp-meta-fields

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

maheshwaghmare/wp-meta-fields
=============================

Register Custom Fields for any WordPress theme or plugin. Build for developer.

1.0.10(6y ago)12551[4 issues](https://github.com/maheshwaghmare/wp-meta-fields/issues)[1 PRs](https://github.com/maheshwaghmare/wp-meta-fields/pulls)MITPHPPHP &gt;=5.3.0CI failing

Since Aug 2Pushed 6y ago2 watchersCompare

[ Source](https://github.com/maheshwaghmare/wp-meta-fields)[ Packagist](https://packagist.org/packages/maheshwaghmare/wp-meta-fields)[ Docs](https://github.com/maheshwaghmare/wp-meta-fields)[ RSS](/packages/maheshwaghmare-wp-meta-fields/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (4)Versions (12)Used By (0)

WP Meta Fields
==============

[](#wp-meta-fields)

Register meta fields for WordPress theme and plugns. Build for WordPress developers.

### Using with Composer

[](#using-with-composer)

**Install Library**

If you have not composer.json then initialize it with command `composer init`.

if you already have the composer.json then use below command to install the package.

```
composer require maheshwaghmare/wp-meta-fields
```

**How to use?**

```
// Load files.
require_once 'vendor/autoload.php';

// Add meta box "Example Meta Box" for the post type 'post' and 'page'.
mf_add_meta_box( array(
	'id'       => 'example-meta-box',
	'title'    => __( 'Example Meta Box' ),
	'screen'   => array( 'post', 'page' ),
	'context'  => 'normal',
	'priority' => 'default',
	'fields'   => array(
		'prefix-1-text' => array(
			'type'        => 'text',
			'title'       => __( 'Text Field', 'textdomain' ),
			'description' => __( 'Simple text field for demonstration purpose.', 'textdomain' ),
			'hint'        => __( 'This is the Text Field for storing the text data for demonstration purpose.', 'textdomain' ),
			'default'     => '',
		),
	)
));
```

Here, We have added a one Text Field for `page` and `post` types.

Our text field meta key is `prefix-1-text`.

We can get the meta filed value with shortcode like `[mf meta_key="prefix-1-text"]`

We can register many other input fields like `text`, `textarea`, `password`, `color` etc. See **Field Types**.

**Remove package**

```
composer remove maheshwaghmare/wp-meta-fields --update-with-dependencies
```

### How to add into theme/plugin?

[](#how-to-add-into-themeplugin)

1. Download latest zip of framework and unzip into your theme/plugin.
2. Add below code to initialize framework.

```
require_once 'wp-meta-fields/wp-meta-fields.php';
```

You can organize your directory structure as per your requirement. Instead of adding framework in root directory of plugin/theme, I'll use the `inc` directory. To add the framework.

1. Create `inc` directory in your plugin/theme.
2. Unzip latest release of `WP Meta Fields` into `inc` directory.
3. Include it into your plugin/theme by adding below code.

```
require_once 'inc/wp-meta-fields/wp-meta-fields.php';

```

NOTE: Make sure you have the latest version `wp-meta-fields`. Get the latest version from [wp-meta-fields](https://github.com/maheshwaghmare/wp-meta-fields)

### Use sample plugin

[](#use-sample-plugin)

To know how to integrate meta field framework into plugin, Use the [sample plugin](https://github.com/maheshwaghmare/wp-meta-fields-sample-plugin/)

### How to add meta box?

[](#how-to-add-meta-box)

Use function `mf_add_meta_box()` to register meta box and its meta fields. It contain parameters which are used for WordPress function [add\_meta\_box()](https://developer.wordpress.org/reference/functions/add_meta_box/)

E.g.

Register meta box for post type `Post`.

```
mf_add_meta_box( array(
	'id'       => 'example-all-fields',
	'title'    => __( 'Example - All Fields' ),
	'screen'   => array( 'post' ),
	'context'  => 'normal',
	'priority' => 'default',
	'fields'   => array(
		// ..
	)
));
```

Where,

ParameterDescription`id`(string) (Required) Meta box ID (used in the 'id' attribute for the meta box).`title`(string) (Required) Title of the meta box.`screen`(string`context`(string) (Optional) The context within the screen where the boxes should display. Available contexts vary from screen to screen. Post edit screen contexts include 'normal', 'side', and 'advanced'. Comments screen contexts include 'normal' and 'side'. Menus meta boxes (accordion sections) all use the 'side' context. Global. `Default value: 'advanced'``priority`(string) (Optional) The priority within the context where the boxes should show ('high', 'low'). `Default value: 'default'`### How to add fields?

[](#how-to-add-fields)

Register single `text` field which have a unique meta key `prefix-1-text` our above registered meta box.

```
mf_add_meta_box( array(
	'id'       => 'example-meta-box',
	'title'    => __( 'Example Meta Box' ),
	'screen'   => array( 'post' ),
	'context'  => 'normal',
	'priority' => 'default',
	'fields'   => array(
		'prefix-1-text' => array(
			'type'        => 'text',
			'title'       => __( 'Text Field', 'textdomain' ),
			'description' => __( 'Simple text field for demonstration purpose.', 'textdomain' ),
			'hint'        => __( 'This is the Text Field for storing the text data for demonstration purpose.', 'textdomain' ),
			'default'     => '',
		),
	)
));
```

Here,

ParameterDescription`prefix-1-text`Unique meta key.`type`Field type.`title`Field title.`description`Field description.`hint`Field hint.`default`Field default value.Above registered field is looks like below screenshot in the post edit window.

[![All Meta Box](https://camo.githubusercontent.com/b6f984965d903050bc3e78b6415223054e418a7e2ac33438c07e2014b91c5871/68747470733a2f2f692e696d6775722e636f6d2f326b3566304e442e706e67)](https://camo.githubusercontent.com/b6f984965d903050bc3e78b6415223054e418a7e2ac33438c07e2014b91c5871/68747470733a2f2f692e696d6775722e636f6d2f326b3566304e442e706e67)

### How to print/retrieve meta field value.

[](#how-to-printretrieve-meta-field-value)

To retrieve/print the value of our registered field `prefix-1-text` use:

```
[mf meta_key='prefix-1-text']

or

mf_meta( 'prefix-1-text' );

or

echo mf_get_meta( 'prefix-1-text' );
```

---

1. Use shortcode `[mf meta_key="META_KEY" post_id="POST_ID"]` to `print` the meta value.

E.g. `[mf meta_key='prefix-1-text']`By default it get the current post ID by using function `get_the_ID()`.

OR `[mf meta_key='prefix-1-text' post_id='46']`Specific post meta value by passing post ID.

2. Use function `mf_meta()` to `print` the meta value.

E.g. ``By default it get the current post ID by using function `get_the_ID()`.

OR ``Specific post meta value by passing post ID.

3. Use function `mf_get_meta()` to `retrieve` the meta value.

E.g. ``By default it get the current post ID by using function `get_the_ID()`.

OR ``Specific post meta value by passing post ID. E.g.

### Field Types

[](#field-types)

Now, Framework support below build in HTML5 field support.

- text
- textarea
- password
- color
- date
- datetime-local
- email
- month
- number
- time
- week
- url
- checkbox
- radio
- select

### Examples

[](#examples)

#### All Meta Field:

[](#all-meta-field)

```
/**
 * Meta Fields (Screen - Normal)
 */
mf_add_meta_box( array(
	'id'       => 'example-all-fields',
	'title'    => __( 'Example - All Fields' ),
	'screen'   => array( 'post' ),
	'context'  => 'normal',
	'priority' => 'default',
	'fields' => array(
		'prefix-1-text' => array(
			'type'        => 'text',
			'title'       => 'Text Field',
			'description' => 'Text Field field description goes here.',
			'hint' => 'Text Field field description goes here.',
			'default'     => '',
		),
		'prefix-1-textarea' => array(
			'type'        => 'textarea',
			'title'       => 'Textarea',
			'description' => 'Textarea field description goes here.',
			'hint' => 'Textarea field description goes here.',
			'default'     => '',
		),
		'prefix-1-password' => array(
			'type'        => 'password',
			'title'       => 'Password',
			'description' => 'Password field description goes here.',
			'hint' => 'Password field description goes here.',
			'default'     => '',
		),
		'prefix-1-color' => array(
			'type'        => 'color',
			'title'       => 'Color',
			'description' => 'Color field description goes here.',
			'hint' => 'Color field description goes here.',
			'default'     => '#f3f3f3',
		),
		'prefix-1-date' => array(
			'type'        => 'date',
			'title'       => 'Date',
			'description' => 'Date field description goes here.',
			'hint' => 'Date field description goes here.',
			'default'     => '',
		),
		'prefix-1-datetime-local' => array(
			'type'        => 'datetime-local',
			'title'       => 'Date Time Local',
			'description' => 'Date Time Local field description goes here.',
			'hint' => 'Date Time Local field description goes here.',
			'default'     => '',
		),
		'prefix-1-email' => array(
			'type'        => 'email',
			'title'       => 'Email',
			'description' => 'Email field description goes here.',
			'hint' => 'Email field description goes here.',
			'default'     => '',
		),
		'prefix-1-month' => array(
			'type'        => 'month',
			'title'       => 'Month',
			'description' => 'Month field description goes here.',
			'hint' => 'Month field description goes here.',
			'default'     => '',
		),
		'prefix-1-number' => array(
			'type'        => 'number',
			'title'       => 'Number',
			'description' => 'Number field description goes here.',
			'hint' => 'Number field description goes here.',
			'default'     => '',
		),
		'prefix-1-time' => array(
			'type'        => 'time',
			'title'       => 'Time',
			'description' => 'Time field description goes here.',
			'hint' => 'Time field description goes here.',
			'default'     => '',
		),
		'prefix-1-week' => array(
			'type'        => 'week',
			'title'       => 'Week',
			'description' => 'Week field description goes here.',
			'hint' => 'Week field description goes here.',
			'default'     => '',
		),
		'prefix-1-url' => array(
			'type'        => 'url',
			'title'       => 'Url',
			'description' => 'Url field description goes here.',
			'hint' => 'Url field description goes here.',
			'default'     => '',
		),
		'prefix-1-checkbox' => array(
			'type'        => 'checkbox',
			'title'       => 'Checkbox',
			'description' => 'Checkbox field description goes here.',
			'hint'        => 'Checkbox field description goes here.',
			'default'     => true,
		),
		'prefix-1-radio' => array(
			'type'        => 'radio',
			'title'       => 'Radio',
			'description' => 'Radio field description goes here.',
			'hint' => 'Radio field description goes here.',
			'default'     => 'one',
			'choices' => array(
				'one'   => 'One',
				'two'   => 'Two',
				'three' => 'Three',
			),
		),
		'prefix-1-select' => array(
			'type'        => 'select',
			'title'       => 'Select',
			'description' => 'Select field description goes here.',
			'hint' => 'Select field description goes here.',
			'default'     => 'one',
			'choices' => array(
				'one'   => 'One',
				'two'   => 'Two',
				'three' => 'Three',
			),
		),
	)
) );
```

It generate the meta box and meta fields like below screenshot.

[![All Meta Box](https://camo.githubusercontent.com/47ae3a3c88651f5bac8105026d2e9cb3b7b05b11a4bc99724cdf441e12368a6d/68747470733a2f2f692e696d6775722e636f6d2f73324a6f7271512e706e67)](https://camo.githubusercontent.com/47ae3a3c88651f5bac8105026d2e9cb3b7b05b11a4bc99724cdf441e12368a6d/68747470733a2f2f692e696d6775722e636f6d2f73324a6f7271512e706e67)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Recently: every ~0 days

Total

11

Last Release

2212d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4434582?v=4)[Mahesh Waghmare](/maintainers/maheshwaghmare)[@maheshwaghmare](https://github.com/maheshwaghmare)

---

Top Contributors

[![maheshwaghmare](https://avatars.githubusercontent.com/u/4434582?v=4)](https://github.com/maheshwaghmare "maheshwaghmare (45 commits)")

---

Tags

wordpresswordpress-metabox-optionswordpress-metaboxeswordpress-pluginwordpresspost meta

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/maheshwaghmare-wp-meta-fields/health.svg)

```
[![Health](https://phpackages.com/badges/maheshwaghmare-wp-meta-fields/health.svg)](https://phpackages.com/packages/maheshwaghmare-wp-meta-fields)
```

###  Alternatives

[roots/bedrock

WordPress boilerplate with Composer, easier configuration, and an improved folder structure

6.5k441.8k2](/packages/roots-bedrock)[cedaro/gravity-forms-iframe

Embed a Gravity Form on any site using an iframe.

1563.0k](/packages/cedaro-gravity-forms-iframe)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
