azi/raskoh

Raskoh - easy wordpress CPT and Taxonomy registration

1.4.1 2017-09-21 04:51 UTC

This package is auto-updated.

Last update: 2024-11-15 08:06:01 UTC


README

Registring custom post types and taxonomies in wordpress is not a headache anymore. Raskoh will make your life simpler.

Usage in theme functions.php

Install

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";

Usage

Register a Post Type

to register a post type

$music = new Raskoh\PostType("Music");
$music->register();
Add a Taxonomy

register a taxonomy along with post type

$music = Raskoh\PostType::getInstance("Music");
$music->taxonomy('Singer')->register();
Restrict Posts by Term

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();
Register Multiple Taxonomies
$music = Raskoh\PostType::getInstance("Music");
$music->taxonomy(['singer','genre'])->register();
Set Icons

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}