{"id":22319760,"url":"https://github.com/maheshwaghmare/wp-meta-fields","last_synced_at":"2025-07-29T13:31:55.171Z","repository":{"id":62522616,"uuid":"169264828","full_name":"maheshwaghmare/wp-meta-fields","owner":"maheshwaghmare","description":"Simple WordPress custom fields framework easy integrate with any theme and plugins.","archived":false,"fork":false,"pushed_at":"2020-04-23T14:24:37.000Z","size":52,"stargazers_count":11,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T04:44:28.506Z","etag":null,"topics":["wordpress","wordpress-metabox-options","wordpress-metaboxes","wordpress-plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maheshwaghmare.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-05T15:38:24.000Z","updated_at":"2024-04-14T04:44:28.507Z","dependencies_parsed_at":"2022-11-02T14:01:02.117Z","dependency_job_id":null,"html_url":"https://github.com/maheshwaghmare/wp-meta-fields","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maheshwaghmare%2Fwp-meta-fields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maheshwaghmare%2Fwp-meta-fields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maheshwaghmare%2Fwp-meta-fields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maheshwaghmare%2Fwp-meta-fields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maheshwaghmare","download_url":"https://codeload.github.com/maheshwaghmare/wp-meta-fields/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228017899,"owners_count":17856841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["wordpress","wordpress-metabox-options","wordpress-metaboxes","wordpress-plugin"],"created_at":"2024-12-04T00:10:59.885Z","updated_at":"2024-12-04T00:11:00.778Z","avatar_url":"https://github.com/maheshwaghmare.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP Meta Fields\n\nRegister meta fields for WordPress theme and plugns. Build for WordPress developers.\n\n### Using with Composer\n\n**Install Library**\n\nIf you have not composer.json then initialize it with command `composer init`.\n\nif you already have the composer.json then use below command to install the package.\n\n```php\ncomposer require maheshwaghmare/wp-meta-fields\n```\n\n**How to use?**\n\n```php\n// Load files.\nrequire_once 'vendor/autoload.php';\n\n// Add meta box \"Example Meta Box\" for the post type 'post' and 'page'.\nmf_add_meta_box( array(\n\t'id'       =\u003e 'example-meta-box',\n\t'title'    =\u003e __( 'Example Meta Box' ),\n\t'screen'   =\u003e array( 'post', 'page' ),\n\t'context'  =\u003e 'normal',\n\t'priority' =\u003e 'default',\n\t'fields'   =\u003e array(\n\t\t'prefix-1-text' =\u003e array(\n\t\t\t'type'        =\u003e 'text',\n\t\t\t'title'       =\u003e __( 'Text Field', 'textdomain' ),\n\t\t\t'description' =\u003e __( 'Simple text field for demonstration purpose.', 'textdomain' ),\n\t\t\t'hint'        =\u003e __( 'This is the Text Field for storing the text data for demonstration purpose.', 'textdomain' ),\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t)\n));\n```\n\nHere, We have added a one Text Field for `page` and `post` types.\n\nOur text field meta key is `prefix-1-text`.\n\nWe can get the meta filed value with shortcode like `[mf meta_key=\"prefix-1-text\"]`\n\nWe can register many other input fields like `text`, `textarea`, `password`, `color` etc. See **Field Types**.\n\n**Remove package**\n\n```php\ncomposer remove maheshwaghmare/wp-meta-fields --update-with-dependencies\n```\n\n\n### How to add into theme/plugin?\n\n1. Download latest zip of framework and unzip into your theme/plugin.\n2. Add below code to initialize framework.\n\n```php\nrequire_once 'wp-meta-fields/wp-meta-fields.php';\n```\n\nYou 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.\n\n1. Create `inc` directory in your plugin/theme.\n2. Unzip latest release of `WP Meta Fields` into `inc` directory.\n3. Include it into your plugin/theme by adding below code.\n\n```\nrequire_once 'inc/wp-meta-fields/wp-meta-fields.php';\n```\n\nNOTE: 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)\n\n### Use sample plugin\n\nTo know how to integrate meta field framework into plugin, Use the [sample plugin](https://github.com/maheshwaghmare/wp-meta-fields-sample-plugin/)\n\n### How to add meta box?\n\nUse 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/)\n\nE.g.\n\nRegister meta box for post type `Post`.\n```php\nmf_add_meta_box( array(\n\t'id'       =\u003e 'example-all-fields',\n\t'title'    =\u003e __( 'Example - All Fields' ),\n\t'screen'   =\u003e array( 'post' ),\n\t'context'  =\u003e 'normal',\n\t'priority' =\u003e 'default',\n\t'fields'   =\u003e array(\n\t\t// ..\n\t)\n));\n\n```\n\nWhere,\n\n| Parameter | Description |\n|-----------------|-----------------|\n|`id` | (string) (Required) Meta box ID (used in the 'id' attribute for the meta box). |\n| `title` |\t(string) (Required) Title of the meta box.|\n| `screen`|\t(string|array|WP_Screen) (Optional) The screen or screens on which to show the box (such as a post type, 'link', or 'comment'). Accepts a single screen ID, WP_Screen object, or array of screen IDs. Default is the current screen. If you have used add_menu_page() or add_submenu_page() to create a new screen (and hence screen_id), make sure your menu slug conforms to the limits of sanitize_key() otherwise the 'screen' menu may not correctly render on your page. `Default value: null`|\n| `context`|\t(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'`|\n| `priority`\t|(string) (Optional) The priority within the context where the boxes should show ('high', 'low'). `Default value: 'default'`|\n\n### How to add fields?\n\nRegister single `text` field which have a unique meta key `prefix-1-text` our above registered meta box.\n\n```php\nmf_add_meta_box( array(\n\t'id'       =\u003e 'example-meta-box',\n\t'title'    =\u003e __( 'Example Meta Box' ),\n\t'screen'   =\u003e array( 'post' ),\n\t'context'  =\u003e 'normal',\n\t'priority' =\u003e 'default',\n\t'fields'   =\u003e array(\n\t\t'prefix-1-text' =\u003e array(\n\t\t\t'type'        =\u003e 'text',\n\t\t\t'title'       =\u003e __( 'Text Field', 'textdomain' ),\n\t\t\t'description' =\u003e __( 'Simple text field for demonstration purpose.', 'textdomain' ),\n\t\t\t'hint'        =\u003e __( 'This is the Text Field for storing the text data for demonstration purpose.', 'textdomain' ),\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t)\n));\n```\n\nHere,\n\n| Parameter | Description |\n|-----------------|-----------------|\n| `prefix-1-text` | Unique meta key. |\n| `type`          | Field type. |\n| `title`         | Field title. |\n| `description`   | Field description. |\n| `hint`          | Field hint. |\n| `default`       | Field default value. |\n\nAbove registered field is looks like below screenshot in the post edit window.\n\n![All Meta Box](https://i.imgur.com/2k5f0ND.png)\n\n### How to print/retrieve meta field value.\n\nTo retrieve/print the value of our registered field `prefix-1-text` use:\n\n```php\n[mf meta_key='prefix-1-text']\n\nor\n\nmf_meta( 'prefix-1-text' );\n\nor\n\necho mf_get_meta( 'prefix-1-text' );\n```\n\n---\n\n1. Use shortcode `[mf meta_key=\"META_KEY\" post_id=\"POST_ID\"]` to `print` the meta value.\n\nE.g. `[mf meta_key='prefix-1-text']`\nBy default it get the current post ID by using function `get_the_ID()`.\n\nOR `[mf meta_key='prefix-1-text' post_id='46']`\nSpecific post meta value by passing post ID.\n\n2. Use function `mf_meta()` to `print` the meta value.\n\nE.g. `\u003c?php mf_meta( 'prefix-1-text' ); ?\u003e`\nBy default it get the current post ID by using function `get_the_ID()`.\n\nOR `\u003c?php mf_meta( 'prefix-1-text', 46 ); ?\u003e`\nSpecific post meta value by passing post ID.\n\n3. Use function `mf_get_meta()` to `retrieve` the meta value.\n\nE.g. `\u003c?php echo mf_get_meta( 'prefix-1-text' ); ?\u003e`\nBy default it get the current post ID by using function `get_the_ID()`.\n\nOR `\u003c?php echo mf_get_meta( 'prefix-1-text', 46 ); ?\u003e`\nSpecific post meta value by passing post ID. E.g.\n\n### Field Types\n\nNow, Framework support below build in HTML5 field support.\n\n- text\n- textarea\n- password\n- color\n- date\n- datetime-local\n- email\n- month\n- number\n- time\n- week\n- url\n- checkbox\n- radio\n- select\n\n### Examples\n\n#### All Meta Field:\n\n```php\n/**\n * Meta Fields (Screen - Normal)\n */\nmf_add_meta_box( array(\n\t'id'       =\u003e 'example-all-fields',\n\t'title'    =\u003e __( 'Example - All Fields' ),\n\t'screen'   =\u003e array( 'post' ),\n\t'context'  =\u003e 'normal',\n\t'priority' =\u003e 'default',\n\t'fields' =\u003e array(\n\t\t'prefix-1-text' =\u003e array(\n\t\t\t'type'        =\u003e 'text',\n\t\t\t'title'       =\u003e 'Text Field',\n\t\t\t'description' =\u003e 'Text Field field description goes here.',\n\t\t\t'hint' =\u003e 'Text Field field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-textarea' =\u003e array(\n\t\t\t'type'        =\u003e 'textarea',\n\t\t\t'title'       =\u003e 'Textarea',\n\t\t\t'description' =\u003e 'Textarea field description goes here.',\n\t\t\t'hint' =\u003e 'Textarea field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-password' =\u003e array(\n\t\t\t'type'        =\u003e 'password',\n\t\t\t'title'       =\u003e 'Password',\n\t\t\t'description' =\u003e 'Password field description goes here.',\n\t\t\t'hint' =\u003e 'Password field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-color' =\u003e array(\n\t\t\t'type'        =\u003e 'color',\n\t\t\t'title'       =\u003e 'Color',\n\t\t\t'description' =\u003e 'Color field description goes here.',\n\t\t\t'hint' =\u003e 'Color field description goes here.',\n\t\t\t'default'     =\u003e '#f3f3f3',\n\t\t),\n\t\t'prefix-1-date' =\u003e array(\n\t\t\t'type'        =\u003e 'date',\n\t\t\t'title'       =\u003e 'Date',\n\t\t\t'description' =\u003e 'Date field description goes here.',\n\t\t\t'hint' =\u003e 'Date field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-datetime-local' =\u003e array(\n\t\t\t'type'        =\u003e 'datetime-local',\n\t\t\t'title'       =\u003e 'Date Time Local',\n\t\t\t'description' =\u003e 'Date Time Local field description goes here.',\n\t\t\t'hint' =\u003e 'Date Time Local field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-email' =\u003e array(\n\t\t\t'type'        =\u003e 'email',\n\t\t\t'title'       =\u003e 'Email',\n\t\t\t'description' =\u003e 'Email field description goes here.',\n\t\t\t'hint' =\u003e 'Email field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-month' =\u003e array(\n\t\t\t'type'        =\u003e 'month',\n\t\t\t'title'       =\u003e 'Month',\n\t\t\t'description' =\u003e 'Month field description goes here.',\n\t\t\t'hint' =\u003e 'Month field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-number' =\u003e array(\n\t\t\t'type'        =\u003e 'number',\n\t\t\t'title'       =\u003e 'Number',\n\t\t\t'description' =\u003e 'Number field description goes here.',\n\t\t\t'hint' =\u003e 'Number field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-time' =\u003e array(\n\t\t\t'type'        =\u003e 'time',\n\t\t\t'title'       =\u003e 'Time',\n\t\t\t'description' =\u003e 'Time field description goes here.',\n\t\t\t'hint' =\u003e 'Time field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-week' =\u003e array(\n\t\t\t'type'        =\u003e 'week',\n\t\t\t'title'       =\u003e 'Week',\n\t\t\t'description' =\u003e 'Week field description goes here.',\n\t\t\t'hint' =\u003e 'Week field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-url' =\u003e array(\n\t\t\t'type'        =\u003e 'url',\n\t\t\t'title'       =\u003e 'Url',\n\t\t\t'description' =\u003e 'Url field description goes here.',\n\t\t\t'hint' =\u003e 'Url field description goes here.',\n\t\t\t'default'     =\u003e '',\n\t\t),\n\t\t'prefix-1-checkbox' =\u003e array(\n\t\t\t'type'        =\u003e 'checkbox',\n\t\t\t'title'       =\u003e 'Checkbox',\n\t\t\t'description' =\u003e 'Checkbox field description goes here.',\n\t\t\t'hint'        =\u003e 'Checkbox field description goes here.',\n\t\t\t'default'     =\u003e true,\n\t\t),\n\t\t'prefix-1-radio' =\u003e array(\n\t\t\t'type'        =\u003e 'radio',\n\t\t\t'title'       =\u003e 'Radio',\n\t\t\t'description' =\u003e 'Radio field description goes here.',\n\t\t\t'hint' =\u003e 'Radio field description goes here.',\n\t\t\t'default'     =\u003e 'one',\n\t\t\t'choices' =\u003e array(\n\t\t\t\t'one'   =\u003e 'One',\n\t\t\t\t'two'   =\u003e 'Two',\n\t\t\t\t'three' =\u003e 'Three',\n\t\t\t),\n\t\t),\n\t\t'prefix-1-select' =\u003e array(\n\t\t\t'type'        =\u003e 'select',\n\t\t\t'title'       =\u003e 'Select',\n\t\t\t'description' =\u003e 'Select field description goes here.',\n\t\t\t'hint' =\u003e 'Select field description goes here.',\n\t\t\t'default'     =\u003e 'one',\n\t\t\t'choices' =\u003e array(\n\t\t\t\t'one'   =\u003e 'One',\n\t\t\t\t'two'   =\u003e 'Two',\n\t\t\t\t'three' =\u003e 'Three',\n\t\t\t),\n\t\t),\n\t)\n) );\n```\nIt generate the meta box and meta fields like below screenshot.\n\n![All Meta Box](https://i.imgur.com/s2JorqQ.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaheshwaghmare%2Fwp-meta-fields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaheshwaghmare%2Fwp-meta-fields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaheshwaghmare%2Fwp-meta-fields/lists"}