Registring custom post types and taxonomies in wordpress is not a headache anymore. Raskoh will make your life simpler.
You can insall Raskoh as a wordpress plugin by downloading the package and pulling it in wp-content/plugins
folder or
using composer.
Paste this in composer.json
file
{
"require" : {
"azi/raskoh" : "1.*"
}
}
or just run this command in your project.
$ composer require azi/raskoh
include composers autoloader in your theme's functions.php
require_once "vendor/autoloader.php";
to register a post type
$music = new Raskoh\PostType("Music");
$music->register();
register a taxonomy along with post type
$music = Raskoh\PostType::getInstance("Music");
$music->taxonomy('Singer')->register();
if you want to add Terms dropdown on WordPress admin interface to restrict posts by terms. just pass a second boolean to
php PostType::taxonomy($name, $filters = false)
method.
$music = Raskoh\PostType::getInstance("Music");
$music->taxonomy('Singer', true)->register();
$music = Raskoh\PostType::getInstance("Music");
$music->taxonomy(['singer','genre'])->register();
you can also set icons to your post type
$music = Raskoh\PostType::getInstance("Music");
$music->taxonomy('Singer')->setIcon('dashicons-format-audioy')->register();
you can pass all other arguments listed at Codex for wp_register_post_type()
like this
$CPT = Raskoh\PostType::getInstance();
$CPT->set{ArgumentName}