Download the PHP package aurooba/cpt without Composer
On this page you can find all versions of the php package aurooba/cpt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cpt
Custom Post Type and Taxonomies Generator
Quickly register custom post types and associated taxonomies with intelligent defaults in your WordPress projects.
For complete documentation of Custom Post Type registration, see https://developer.wordpress.org/reference/functions/register_post_type/
For complete documentation of Taxonomy registration, see https://developer.wordpress.org/reference/functions/register_taxonomy/
Minimum Requirements
- PHP: 7.0
- PHP 7.4+ is recommended
- WordPress: 5.0
- Tested up to WP 5.6.2
Installation
The easiest way is to install this through Composer with:
Make sure you have composer autoload set up where you are adding the package.
For themes, in your functions.php
file:
For plugins, in your main plugin file, near the top:
Usage
Don't see an option you use often and would love for it to be easier too? Open an issue or pop it into the Discussion area, let's make it happen. :)
Have a question about your specific use case? Ask in a support discussion.
Basic Usage
The class, by default, takes in just one parameter: a singular name, like resource
. It's smart enough to convert resource
into resources
, country
into countries
, potato
into potatoes
, goose
into geese
, and handles some exceptions as well.
At this time, it is not smart enough to handle uncountable nouns such as rice
, tea
, knowledge
, etc. This is a planned addition, coming later.
Customized Usage
Icons
The default icon, set up in the class is the screenoptions
Dashicon, purely because I like it.
Feel free to pass a different Dashicon to your class as shown in this different icon example.
You can also pass custom SVG icons, as shown in this custom svg icon example.
Taxonomies
The class can also generate a new taxonomy to attach to the CPT.
Examples
Register a basic Custom Post Type:
Register and associate a basic taxonomy with the Custom Post Type:
Register a Custom Post Type with a different icon
Register a Custom Post Type with a custom icon
Create a customized Custom Post Type:
Create a customized taxonomy:
Attach an existing taxonomy:
Contributing
Contributors are welcome! Come help extend, test, and improve this package so it becomes an insanely helpful library. Check out CONTRIBUTING.md for more information.
License
Created by Aurooba Ahmed. Licensed under the terms of the GPL v2 or later.