{"id":13660293,"url":"https://github.com/soberwp/models","last_synced_at":"2025-04-24T19:30:45.674Z","repository":{"id":57054531,"uuid":"77862065","full_name":"soberwp/models","owner":"soberwp","description":"WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files","archived":true,"fork":false,"pushed_at":"2020-10-27T10:03:52.000Z","size":742,"stargazers_count":172,"open_issues_count":2,"forks_count":15,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-17T09:18:26.253Z","etag":null,"topics":["json","json-configuration","php","wordpress","wordpress-plugin","yaml"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soberwp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-02T21:11:04.000Z","updated_at":"2024-05-24T00:07:39.000Z","dependencies_parsed_at":"2022-08-24T04:11:40.930Z","dependency_job_id":null,"html_url":"https://github.com/soberwp/models","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soberwp%2Fmodels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soberwp%2Fmodels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soberwp%2Fmodels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soberwp%2Fmodels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soberwp","download_url":"https://codeload.github.com/soberwp/models/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250693471,"owners_count":21472268,"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":["json","json-configuration","php","wordpress","wordpress-plugin","yaml"],"created_at":"2024-08-02T05:01:19.808Z","updated_at":"2025-04-24T19:30:45.227Z","avatar_url":"https://github.com/soberwp.png","language":"PHP","funding_links":["https://paypal.me/darrenjacoby"],"categories":["PHP"],"sub_categories":[],"readme":"# Models\n\nModels is a WordPress plugin allowing you to create custom post types and taxonomies using JSON, YAML or PHP files.\n\n**[You can now set post types and taxonomies using Intervention 2.x.x.](https://github.com/soberwp/intervention)**\n\n## Installation\n\n#### Composer:\n\nRecommended methods: \n\n[Roots Bedrock](https://roots.io/bedrock/)\n```shell\n$ composer require soberwp/models:1.1.0\n```\n**Models** is a mu-plugin so it doesn't have to be activated.\n\n[Roots Sage](https://roots.io/sage/)\n```shell\n$ composer require soberwp/models:1.1.0-p\n```\n\n#### Manual:\n\n* Download the [zip file](https://github.com/soberwp/models/archive/master.zip)\n* Unzip to your sites plugin folder\n* Activate via WordPress\n\n#### Requirements:\n\n* [PHP](http://php.net/manual/en/install.php) \u003e= 5.6.x\n\n## Setup\n\nBy default, create folder `models/` within the active theme directory. \n\nIf you are a [Roots Sage](https://roots.io/sage/) the default folder is `app/models/`\n\nAlternatively, you can define a custom path using the filter below within your themes `functions.php` file:\n\n```php\nadd_filter('sober/models/path', function () {\n    return get_stylesheet_directory() . '/your-custom-folder';\n});\n```\n\nThat's it, now go ahead and add `model-name.json` files, in the folder or subfolders to begin creating your models. Use [Unravel](https://github.com/soberwp/unravel) to automatically move the config files outside of your theme path for better separation of concerns.\n\n## Usage\n\nThe data structure follows a similar data structure to WordPress taxonomies and post types arrays, so if an config option is missing from the examples below, follow the developer's reference and place it within `\"config\": {}`\n\nIf values are not specified, defaults are the same as WordPress defaults.\n\nAdditionally, if the [Extended CPTs](https://github.com/johnbillion/extended-cpts) library is available, Models will use it when registering your post types and taxonomies instead allowing extended functionality within your Models.\n\nExtracted examples presented below are in JSON format.\n\n### Post Types\n\nCreate a custom post type. \n\n#### Required:\n\n* [post-type-required.json](.github/json/post-type-required.json)\n* [post-type-required.php](.github/php/post-type-required.php)\n* [post-type-required.yaml](.github/yaml/post-type-required.yaml)\n\n```json\n{\n  \"type\": \"post-type\",\n  \"name\": \"book\"\n}\n```\n\n#### Basic:\n\n* [post-type-basic.json](.github/json/post-type-basic.json)\n* [post-type-basic.php](.github/php/post-type-basic.php)\n* [post-type-basic.yaml](.github/yaml/post-type-basic.yaml)\n\n```json\n{\n  \"type\": \"cpt\",\n  \"name\": \"book\",\n  \"supports\": [\n    \"title\", \"editor\", \"thumbnail\"\n  ],\n  \"labels\": {\n    \"has_one\": \"Book\",\n    \"has_many\": \"Books\",\n    \"text_domain\": \"sage\"\n  }\n}\n```\n\nIn the above example, `\"labels\": {}` are redundant because `\"Book\"` and `\"Books\"` would have been generated from `\"name\"`.\n\n#### Multiple:\n\n* [post-type-multiple.json](.github/json/post-type-multiple.json)\n* [post-type-multiple.php](.github/php/post-type-multiple.php)\n* [post-type-multiple.yaml](.github/yaml/post-type-multiple.yaml)\n\n```json\n[\n  {\n    \"type\": \"cpt\",\n    \"name\": \"book\",\n    \"supports\": [\n      \"title\", \"editor\", \"thumbnail\"\n    ]\n  },\n  {\n    \"type\": \"cpt\",\n    \"name\": \"album\",\n    \"supports\": [\n      \"title\", \"editor\", \"comments\"\n    ]\n  }\n]\n```\n\n#### All Fields:\n\n* [post-type-all.json](.github/json/post-type-all.json)\n* [post-type-all.php](.github/php/post-type-all.php)\n* [post-type-all.yaml](.github/yaml/post-type-all.yaml)\n\n#### Post Type Tips:\n\n* `\"active\": false` stops the post type from being created. Default is set to `true`.\n* `\"type\": \"post-type\"` also accepts a shorthand `\"type\": \"cpt\"`;\n\n### Taxonomies\n\nCreate a custom taxonomy.\n\n#### Required:\n\n* [taxonomy-required.json](.github/json/taxonomy-required.json)\n* [taxonomy-required.php](.github/php/taxonomy-required.php)\n* [taxonomy-required.yaml](.github/yaml/taxonomy-required.yaml)\n\n```json\n{\n  \"type\": \"taxonomy\",\n  \"name\": \"genre\"\n}\n```\n\n#### Basic:\n\n* [taxonomy-basic.json](.github/json/taxonomy-basic.json)\n* [taxonomy-basic.php](.github/php/taxonomy-basic.php)\n* [taxonomy-basic.yaml](.github/yaml/taxonomy-basic.yaml)\n\n```json\n{\n  \"type\": \"tax\",\n  \"name\": \"genre\",\n  \"links\": [\n    \"post\", \"book\"\n  ],\n  \"labels\": {\n    \"has_one\": \"Book Genre\",\n    \"has_many\": \"Book Genres\",\n    \"text_domain\": \"sage\"\n  }\n}\n```\n\n`\"links\": (string|array)` assigns the taxonomy to post types. Defaults to `\"links\": \"post\"`\n\n#### Multiple:\n\n* [taxonomy-multiple.json](.github/json/taxonomy-multiple.json)\n* [taxonomy-multiple.php](.github/php/taxonomy-multiple.php)\n* [taxonomy-multiple.yaml](.github/yaml/taxonomy-multiple.yaml)\n\n```json\n[\n  {\n    \"type\": \"category\",\n    \"name\": \"genre\",\n    \"links\": \"book\"\n  },\n  {\n    \"type\": \"tag\",\n    \"name\": \"author\",\n    \"links\": \"book\"\n  }\n]\n```\n\n`\"type\": \"category\"` and `\"type\": \"tag\"` shorthands are explained below under Tips.\n\n#### All Fields:\n\n* [taxonomy-all.json](.github/json/taxonomy-all.json)\n* [taxonomy-all.php](.github/php/taxonomy-all.php)\n* [taxonomy-all.yaml](.github/yaml/taxonomy-all.yaml)\n\n#### Taxonomy Tips:\n\n* `\"active\": false` stops the taxonomy from being created. Default is set to `true`.\n* `\"type\": \"taxonomy\"` also accepts shorthands;\n  * `\"type\": \"tax\"`\n  * `\"type\": \"category\"` or `\"type\": \"cat\"` creates a category taxonomy.\n  * `\"type\": \"tag\"` creates a tag taxonomy.\n  \n## Support\n\n* Follow [@withjacoby](https://twitter.com/withjacoby) on Twitter\n* Buy me a beer or pay my rent, [paypal.me/darrenjacoby](https://paypal.me/darrenjacoby)\n\n## Updates\n\n#### Composer:\n\n* Change the composer.json version to ^1.0.4**\n* Check [CHANGELOG.md](CHANGELOG.md) for any breaking changes before updating.\n\n```shell\n$ composer update\n```\n\n#### WordPress:\n\nIncludes support for [github-updater](https://github.com/afragen/github-updater) to keep track on updates through the WordPress backend.\n* Download [github-updater](https://github.com/afragen/github-updater)\n* Clone [github-updater](https://github.com/afragen/github-updater) to your sites plugins/ folder\n* Activate via WordPress\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoberwp%2Fmodels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoberwp%2Fmodels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoberwp%2Fmodels/lists"}