PHPackages                             arraypress/wp-term-utils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arraypress/wp-term-utils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arraypress/wp-term-utils
========================

A lean WordPress library for working with taxonomies and terms

10PHP

Since Jul 3Pushed 10mo agoCompare

[ Source](https://github.com/arraypress/wp-term-utils)[ Packagist](https://packagist.org/packages/arraypress/wp-term-utils)[ RSS](/packages/arraypress-wp-term-utils/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

WordPress Term Utilities
========================

[](#wordpress-term-utilities)

A lightweight WordPress library for working with taxonomies and terms. Provides clean APIs for term operations, search functionality, and value/label formatting perfect for forms and admin interfaces.

Features
--------

[](#features)

- 🎯 **Clean API**: WordPress-style snake\_case methods with consistent interfaces
- 🔍 **Built-in Search**: Term and taxonomy search with value/label formatting
- 📋 **Form-Ready Options**: Perfect value/label arrays for selects and forms
- 🌳 **Hierarchical Support**: Indented options for hierarchical taxonomies
- 🔗 **Object Relations**: Easy term assignment and management for posts/objects
- 📊 **Meta Operations**: Simple term meta handling with type safety
- 🎨 **Flexible Identifiers**: Use IDs, slugs, names, or objects interchangeably

Requirements
------------

[](#requirements)

- PHP 7.4 or later
- WordPress 5.0 or later

Installation
------------

[](#installation)

```
composer require arraypress/wp-term-utils
```

Basic Usage
-----------

[](#basic-usage)

### Working with Single Terms

[](#working-with-single-terms)

```
use ArrayPress\TermUtils\Term;

// Get term by ID
$term = Term::get( 123, 'category' );

// Get term by identifier (ID, slug, or name)
$term = Term::get_by_identifier( 'tech-news', 'category' );

// Check if term exists
if ( Term::exists( 123, 'category' ) ) {
	// Term exists
}

// Get term meta
$featured = Term::get_meta( 123, 'featured' );

// Get term children
$children = Term::get_children( 123, 'category' );

// Check if term has posts
if ( Term::has_posts( 'tech-news', 'category' ) ) {
	// Term has posts
}

// Get hierarchical path
$path = Term::get_path( 123, 'category' ); // "Parent > Child > Term"
```

### Working with Multiple Terms

[](#working-with-multiple-terms)

```
use ArrayPress\TermUtils\Terms;

// Get multiple terms
$terms = Terms::get( [ 1, 2, 3 ], 'category' );

// Get terms by identifiers
$term_ids = Terms::get_by_identifiers( [ 'tech', 'news', 'sports' ], 'category' );

// Get term names
$names = Terms::get_names( [ 1, 2, 3 ], 'category' );

// Get terms for a post
$post_terms = Terms::get_for_object( 123, 'category' );

// Set terms for a post
Terms::set_for_object( 123, 'category', [ 'tech', 'news' ] );

// Add single term to post
Terms::add_term( 123, 'category', 'breaking-news' );

// Search terms and get options
$options = Terms::search_options( 'tech', 'category' );
// Returns: [['value' => 1, 'label' => 'Technology'], ...]

// Get all terms as options
$all_options = Terms::get_options( 'category' );
// Returns: [1 => 'Technology', 2 => 'News', ...]

// Get hierarchical options (with indentation)
$hierarchical = Terms::get_options( 'category', [], true );
// Returns: [1 => 'Parent', 2 => '— Child', 3 => '—— Grandchild']
```

### Working with Taxonomies

[](#working-with-taxonomies)

```
use ArrayPress\TermUtils\Taxonomy;

// Check if taxonomy exists
if ( Taxonomy::exists( 'product_category' ) ) {
	// Taxonomy exists
}

// Get taxonomy post types
$post_types = Taxonomy::get_post_types( 'category' );

// Get all public taxonomies
$public = Taxonomy::get_public();

// Get taxonomies for post type
$taxonomies = Taxonomy::get_for_post_type( 'product' );

// Get taxonomies as options
$tax_options = Taxonomy::get_options();
// Returns: ['category' => 'Categories', 'post_tag' => 'Tags']

// Search taxonomies
$search_results = Taxonomy::search_options( 'product' );
// Returns: [['value' => 'product_cat', 'label' => 'Product Categories']]
```

### Utility Methods

[](#utility-methods)

```
// Get unused terms
$unused = Terms::get_unused( 'category' );

// Get most used terms
$popular = Terms::get_most_used( 'category', 5 );

// Sanitize term identifiers
$clean_ids = Terms::sanitize( [ '1', 'invalid', '3' ], 'category' );
```

Key Features
------------

[](#key-features)

- **Value/Label Format**: Perfect for forms and selects
- **Hierarchical Support**: Indented options for hierarchical taxonomies
- **Search Functionality**: Built-in term and taxonomy search
- **Object Relations**: Easy term assignment to posts/objects
- **Meta Operations**: Simple term meta handling
- **Flexible Identifiers**: Use IDs, slugs, names, or objects interchangeably

Requirements
------------

[](#requirements-1)

- PHP 7.4+
- WordPress 5.0+

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This project is licensed under the GPL-2.0-or-later License.

Support
-------

[](#support)

- [Documentation](https://github.com/arraypress/wp-term-utils)
- [Issue Tracker](https://github.com/arraypress/wp-term-utils/issues)

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd6eb8aff0903d87eb674d1ba3c5f3653899c0d7661504eb0deb7798ed86b643?d=identicon)[arraypress](/maintainers/arraypress)

---

Top Contributors

[![arraypress](https://avatars.githubusercontent.com/u/22668877?v=4)](https://github.com/arraypress "arraypress (2 commits)")

### Embed Badge

![Health badge](/badges/arraypress-wp-term-utils/health.svg)

```
[![Health](https://phpackages.com/badges/arraypress-wp-term-utils/health.svg)](https://phpackages.com/packages/arraypress-wp-term-utils)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
