diff options
Diffstat (limited to 'Readme.md')
-rw-r--r-- | Readme.md | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..372edc1 --- /dev/null +++ b/Readme.md @@ -0,0 +1,77 @@ +# PostTypes + +> Simple WordPress custom post types. + +## Requirements + +* PHP >=7.2 +* [Composer](https://getcomposer.org/) +* [WordPress](https://wordpress.org) >=5.1 + +## Installation + +#### Install with composer + +Run the following in your terminal to install PostTypes with [Composer](https://getcomposer.org/). + +``` +$ composer require dweipert/posttypes +``` + +PostTypes uses [PSR-4](https://www.php-fig.org/psr/psr-4/) autoloading and can be used with the Composer's autoloader. Below is a basic example of getting started, though your setup may be different depending on how you are using Composer. + +```php +require __DIR__ . '/vendor/autoload.php'; + +use PostTypes\PostType; + +$books = new PostType( 'book' ); + +$books->register(); +``` + +See Composer's [basic usage](https://getcomposer.org/doc/01-basic-usage.md#autoloading) guide for details on working with Composer and autoloading. + +## Basic Usage + +Below is a basic example of setting up a simple book post type with a genre taxonomy. + +```php +// Require the Composer autoloader. +require __DIR__ . '/vendor/autoload.php'; + +// Import PostTypes. +use PostTypes\PostType; +use PostTypes\Taxonomy; + +// Create a book post type. +$books = new PostType( 'book' ); + +// Attach the genre taxonomy (which is created below). +$books->taxonomy( 'genre' ); + +// Hide the date and author columns. +$books->columns()->hide( [ 'date', 'author' ] ); + +// Set the Books menu icon. +$books->icon( 'dashicons-book-alt' ); + +// Register the post type to WordPress. +$books->register(); + +// Create a genre taxonomy. +$genres = new Taxonomy( 'genre' ); + +// Set options for the taxonomy. +$genres->options( [ + 'hierarchical' => false, +] ); + +// Register the taxonomy to WordPress. +$genres->register(); +``` + +## Notes + +* The class has no methods for making custom fields for post types, use [Advanced Custom Fields](https://advancedcustomfields.com) +* Maintained under the [Semantic Versioning Guide](https://semver.org) |