{"id":34910480,"url":"https://github.com/arraypress/wp-register-post-type","last_synced_at":"2026-01-20T16:38:02.280Z","repository":{"id":321243359,"uuid":"1084938206","full_name":"arraypress/wp-register-post-type","owner":"arraypress","description":"A powerful library for registering custom post types in WordPress with smart defaults, automatic label generation, and permalink management.","archived":false,"fork":false,"pushed_at":"2025-11-24T10:22:07.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-27T22:56:19.990Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/arraypress.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-28T11:20:21.000Z","updated_at":"2025-11-24T10:22:11.000Z","dependencies_parsed_at":"2025-10-28T17:12:35.781Z","dependency_job_id":"8668f30d-1223-4d5d-aa0e-1e8bb92c8558","html_url":"https://github.com/arraypress/wp-register-post-type","commit_stats":null,"previous_names":["arraypress/wp-register-post-type"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arraypress/wp-register-post-type","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-register-post-type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-register-post-type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-register-post-type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-register-post-type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arraypress","download_url":"https://codeload.github.com/arraypress/wp-register-post-type/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-register-post-type/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28053391,"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","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-12-26T11:06:48.590Z","updated_at":"2025-12-26T11:06:51.368Z","avatar_url":"https://github.com/arraypress.png","language":"PHP","readme":"# WordPress Register Post Type\n\nA powerful, elegant library for registering custom post types in WordPress with smart defaults, automatic label generation, and permalink management.\n\n## Features\n\n- 🎯 **Simple API** - Register post types with minimal configuration\n- 🏷️ **Auto Labels** - Generates all 28 labels from singular/plural forms\n- 🎨 **Icon Shortcuts** - Use simple names like 'cart' instead of 'dashicons-cart'\n- 📍 **Smart Menu Positioning** - Use semantic positions like 'after:posts'\n- 🔗 **Permalink Management** - Easy slug configuration with auto-flush\n- 📊 **Admin Column Helpers** - Quick thumbnail column setup\n- ✨ **Clean Code** - Modern PHP 7.4+, fully typed, well-documented\n- 🚀 **Zero Config** - Works great with just singular/plural labels\n\n## Installation\n\nInstall via Composer:\n\n```bash\ncomposer require arraypress/wp-register-post-type\n```\n\n## Quick Start\n\n### Minimal Example\n\n```php\nuse function ArrayPress\\WP\\RegisterPostType\\register_custom_post_type;\n\nregister_custom_post_type( 'product', [\n    'labels' =\u003e [\n        'singular' =\u003e 'Product',\n        'plural'   =\u003e 'Products'\n    ]\n] );\n```\n\nThat's it! This creates a fully functional post type with:\n- ✅ All 28 labels auto-generated\n- ✅ Public and queryable\n- ✅ REST API enabled\n- ✅ Archive page enabled\n- ✅ Title, editor, and thumbnail support\n\n### Full Example\n\n```php\nregister_custom_post_type( 'product', [\n    'labels' =\u003e [\n        'singular' =\u003e 'Product',\n        'plural'   =\u003e 'Products'\n    ],\n    'icon'          =\u003e 'cart',              // Simple icon name\n    'supports'      =\u003e [ 'title', 'editor', 'thumbnail', 'excerpt' ],\n    'has_archive'   =\u003e true,\n    'show_in_rest'  =\u003e true,\n    'menu_position' =\u003e 'after:posts',       // Semantic positioning\n    'permalink'     =\u003e [\n        'slug'       =\u003e 'shop/products',\n        'with_front' =\u003e false\n    ],\n    'admin_columns' =\u003e [\n        'thumbnail' =\u003e true                 // Add thumbnail column\n    ]\n] );\n```\n\n## Configuration Options\n\n### Labels\n\nThe library automatically generates all 28 WordPress post type labels from just two inputs:\n\n```php\n'labels' =\u003e [\n    'singular' =\u003e 'Product',\n    'plural'   =\u003e 'Products'  // Optional - auto-pluralized if not provided\n]\n```\n\n**Generated labels include:**\n- name, singular_name, add_new, add_new_item, edit_item\n- new_item, view_item, view_items, search_items\n- not_found, not_found_in_trash, parent_item_colon\n- all_items, archives, attributes, insert_into_item\n- uploaded_to_this_item, featured_image, set_featured_image\n- remove_featured_image, use_featured_image, menu_name\n- filter_items_list, items_list_navigation, items_list\n- item_published, item_published_privately, item_reverted_to_draft\n- item_scheduled, item_updated\n\nYou can override any generated label:\n\n```php\n'labels' =\u003e [\n    'singular'  =\u003e 'Product',\n    'plural'    =\u003e 'Products',\n    'all_items' =\u003e 'All My Products'  // Override specific label\n]\n```\n\n### Icon Shortcuts\n\nUse simple, memorable names instead of full dashicon strings:\n\n| Shortcut | Dashicon |\n|----------|----------|\n| `cart` | dashicons-cart |\n| `product`, `products` | dashicons-products |\n| `store`, `shop` | dashicons-store |\n| `calendar`, `event` | dashicons-calendar |\n| `people`, `team` | dashicons-groups |\n| `book`, `books` | dashicons-book |\n| `portfolio` | dashicons-portfolio |\n| `image`, `images` | dashicons-format-image |\n| `video` | dashicons-format-video |\n| `audio` | dashicons-format-audio |\n| `download` | dashicons-download |\n| `star` | dashicons-star-filled |\n| `heart` | dashicons-heart |\n| `location`, `map` | dashicons-location |\n| `email`, `mail` | dashicons-email |\n\n**Examples:**\n```php\n'icon' =\u003e 'cart'                    // Uses dashicons-cart\n'icon' =\u003e 'dashicons-admin-post'    // Use full dashicon name\n'icon' =\u003e 'data:image/svg+xml...'   // Use base64 SVG\n'icon' =\u003e 'path/to/icon.png'        // Use custom image\n```\n\n### Menu Position\n\nUse semantic positioning instead of remembering numbers:\n\n```php\n'menu_position' =\u003e 'after:posts'     // Right after Posts menu\n'menu_position' =\u003e 'before:media'    // Right before Media menu\n'menu_position' =\u003e 'after:pages'     // Right after Pages\n'menu_position' =\u003e 'after:comments'  // Right after Comments\n'menu_position' =\u003e 30                // Or use numeric position\n```\n\n**Available reference points:**\n- `dashboard` (2)\n- `posts` (5)\n- `media` (10)\n- `pages` (20)\n- `comments` (25)\n- `appearance` (60)\n- `plugins` (65)\n- `users` (70)\n- `tools` (75)\n- `settings` (80)\n\n### Permalink Structure\n\nConfigure custom URL structure:\n\n```php\n'permalink' =\u003e [\n    'slug'       =\u003e 'shop/products',    // Custom slug\n    'with_front' =\u003e false,              // Don't prepend site's base\n    'feeds'      =\u003e true,               // Enable feeds\n    'pages'      =\u003e true                // Enable pagination\n]\n```\n\n**Examples:**\n\n```php\n// Simple slug\n'permalink' =\u003e [\n    'slug' =\u003e 'products'\n]\n// Result: yoursite.com/products/product-name/\n\n// Nested structure\n'permalink' =\u003e [\n    'slug' =\u003e 'shop/products'\n]\n// Result: yoursite.com/shop/products/product-name/\n\n// Disable rewrites entirely\n'permalink' =\u003e [\n    'disabled' =\u003e true\n]\n```\n\n### Admin Columns\n\nQuick shortcuts for common admin columns:\n\n```php\n'admin_columns' =\u003e [\n    'thumbnail' =\u003e true    // Add thumbnail column before title\n]\n```\n\n### Common Options\n\nAll standard `register_post_type()` options are supported:\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `public` | `bool` | `true` | Public facing post type |\n| `has_archive` | `bool` | `true` | Enable archive page |\n| `show_in_rest` | `bool` | `true` | Enable Gutenberg \u0026 REST API |\n| `supports` | `array` | `['title', 'editor', 'thumbnail']` | Features to support |\n| `hierarchical` | `bool` | `false` | Allow parent/child relationships |\n| `capability_type` | `string` | `'post'` | Capability type |\n| `menu_position` | `int\\|string` | `null` | Menu position |\n| `menu_icon` | `string` | `null` | Menu icon |\n\n## Real-World Examples\n\n### E-Commerce Products\n\n```php\nregister_custom_post_type( 'product', [\n    'labels' =\u003e [\n        'singular' =\u003e 'Product',\n        'plural'   =\u003e 'Products'\n    ],\n    'icon'          =\u003e 'cart',\n    'supports'      =\u003e [ 'title', 'editor', 'thumbnail', 'excerpt' ],\n    'has_archive'   =\u003e true,\n    'show_in_rest'  =\u003e true,\n    'menu_position' =\u003e 'after:posts',\n    'permalink'     =\u003e [\n        'slug'       =\u003e 'shop/products',\n        'with_front' =\u003e false\n    ],\n    'admin_columns' =\u003e [\n        'thumbnail' =\u003e true\n    ]\n] );\n```\n\n### Portfolio Items\n\n```php\nregister_custom_post_type( 'portfolio', [\n    'labels' =\u003e [\n        'singular' =\u003e 'Portfolio Item',\n        'plural'   =\u003e 'Portfolio'\n    ],\n    'icon'         =\u003e 'portfolio',\n    'supports'     =\u003e [ 'title', 'editor', 'thumbnail' ],\n    'has_archive'  =\u003e true,\n    'menu_position' =\u003e 'after:pages'\n] );\n```\n\n### Team Members\n\n```php\nregister_custom_post_type( 'team', [\n    'labels' =\u003e [\n        'singular' =\u003e 'Team Member',\n        'plural'   =\u003e 'Team'\n    ],\n    'icon'         =\u003e 'people',\n    'supports'     =\u003e [ 'title', 'editor', 'thumbnail', 'page-attributes' ],\n    'hierarchical' =\u003e true,\n    'has_archive'  =\u003e false,\n    'public'       =\u003e true,\n    'menu_position' =\u003e 'after:users',\n    'admin_columns' =\u003e [\n        'thumbnail' =\u003e true\n    ]\n] );\n```\n\n### Events with Custom Permalink\n\n```php\nregister_custom_post_type( 'event', [\n    'labels' =\u003e [\n        'singular' =\u003e 'Event',\n        'plural'   =\u003e 'Events'\n    ],\n    'icon'         =\u003e 'calendar',\n    'supports'     =\u003e [ 'title', 'editor', 'thumbnail', 'excerpt' ],\n    'has_archive'  =\u003e true,\n    'show_in_rest' =\u003e true,\n    'permalink'    =\u003e [\n        'slug'       =\u003e 'events',\n        'with_front' =\u003e false\n    ]\n] );\n```\n\n### Documentation/Knowledge Base\n\n```php\nregister_custom_post_type( 'documentation', [\n    'labels' =\u003e [\n        'singular' =\u003e 'Documentation',\n        'plural'   =\u003e 'Docs'\n    ],\n    'icon'         =\u003e 'book',\n    'supports'     =\u003e [ 'title', 'editor', 'comments', 'revisions' ],\n    'hierarchical' =\u003e true,\n    'has_archive'  =\u003e true,\n    'show_in_rest' =\u003e true,\n    'permalink'    =\u003e [\n        'slug' =\u003e 'docs'\n    ]\n] );\n```\n\n### Testimonials\n\n```php\nregister_custom_post_type( 'testimonial', [\n    'labels' =\u003e [\n        'singular' =\u003e 'Testimonial'\n        // Plural auto-generated as 'Testimonials'\n    ],\n    'icon'         =\u003e 'star',\n    'supports'     =\u003e [ 'title', 'editor', 'thumbnail' ],\n    'has_archive'  =\u003e false,\n    'show_in_menu' =\u003e true\n] );\n```\n\n## How It Works\n\n### Automatic Label Generation\n\nThe library uses intelligent pluralization:\n\n```php\n'Product' → 'Products'\n'Category' → 'Categories'\n'Person' → 'People' (you should provide this manually)\n```\n\nAll 28 required labels are generated from these two inputs.\n\n### Permalink Management\n\n- Rewrites are automatically configured based on your `permalink` settings\n- Rewrite rules are flushed on plugin activation (no manual flush needed)\n- Supports complex structures like `shop/products/%category%`\n\n### Icon Resolution\n\n1. Checks if it's already a full dashicon name (`dashicons-*`)\n2. Checks if it's a URL or path to an image\n3. Checks if it's a base64 SVG\n4. Looks up shortcut in icon map\n5. Assumes it's a dashicon name and adds prefix\n\n## Function Reference\n\n### `register_custom_post_type( string $post_type, array $config )`\n\nRegister a custom post type.\n\n**Parameters:**\n- `$post_type` (string) - Post type slug (max 20 characters, lowercase)\n- `$config` (array) - Configuration array\n\n**Returns:** `PostType` instance\n\n**Aliases:**\n- `ArrayPress\\WP\\RegisterPostType\\register_post_type()` - Same function\n\n## Requirements\n\n- PHP 7.4 or higher\n- WordPress 5.0 or higher\n\n## Best Practices\n\n1. **Keep slugs short** - Max 20 characters for post type slug\n2. **Use singular form for slug** - `product` not `products`\n3. **Provide both singular and plural** - For best label generation\n4. **Test permalink structure** - Always test your URLs after registration\n\n## Troubleshooting\n\n### Permalinks not working?\n\nTry visiting **Settings → Permalinks** to manually flush rewrite rules.\n\n### Post type not showing in REST API?\n\nMake sure `show_in_rest` is `true` (it is by default).\n\n### Custom icon not showing?\n\nCheck that your icon path is correct or use one of the built-in shortcuts.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nGPL-2.0-or-later\n\n## Credits\n\nDeveloped by [ArrayPress](https://arraypress.com/)\n\n## Support\n\n- [Documentation](https://github.com/arraypress/wp-register-post-type)\n- [Issue Tracker](https://github.com/arraypress/wp-register-post-type/issues)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fwp-register-post-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farraypress%2Fwp-register-post-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fwp-register-post-type/lists"}