itsmejgrant/taxonomy-helper

This package is abandoned and no longer maintained. No replacement package was suggested.

A tiny package to abstract away the pain of creating custom taxonomies in WordPress.

1.0.1 2022-04-04 07:36 UTC

This package is auto-updated.

Last update: 2024-12-17 04:19:45 UTC


README

A super simple abstraction to make creating a custom Taxonomies in WordPress a breeze.

Installation

You can either a) install with composer or b) copy the main the file and require it your functions file.

Composer

In your terminal, in the directory where your composer.json is (usually the theme directory):

composer require itsmejgrant/custom-taxonomy-helper

Then, in your function.php file:

use Itsmejgrant\TaxonomyHelper\Taxonomy

That's it, you're ready to go!

Manual installation

Copy the contents of the Taxonomy.php file and put it whereever makes sense in your theme directory.

Require it whereever you will be using it with:

require 'path/to/your/Taxonomy.php';

Usage

To use the helper, assign a new instance to a variable and manipulate as required. The only required arguments are the name of the taxonomy and either a string or array of post types to assign it to.

Examples:

function assigning_to_one_post_type() {
  $regions = new Taxonomy('Regions', 'posts');
}
add_action('init', 'assigning_to_one_post_type');
function assigning_to_multiple_post_types() {
  $regions = new Taxonomy('Regions', ['posts', 'pages']);
}
add_action('init', 'assigning_to_multiple_post_types');