PHPackages                             achttienvijftien/wp-primary-term - 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. achttienvijftien/wp-primary-term

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

achttienvijftien/wp-primary-term
================================

Primary term selector for WP taxonomies

1.0.0(yesterday)023↑2639.1%proprietaryPHPPHP ^8.3

Since Jun 8Pushed yesterdayCompare

[ Source](https://github.com/achttienvijftien/wp-primary-term)[ Packagist](https://packagist.org/packages/achttienvijftien/wp-primary-term)[ Docs](https://www.1815.nl)[ RSS](/packages/achttienvijftien-wp-primary-term/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (6)Versions (2)Used By (0)

WP Primary Term
===============

[](#wp-primary-term)

Primary term selector for WordPress taxonomies.

Installation (Development)
--------------------------

[](#installation-development)

Install PHP dependencies:

```
composer install
```

Install JavaScript dependencies:

```
yarn
```

Lint
----

[](#lint)

```
yarn lint:js && yarn lint:php

```

Format code:

```
yarn format:js && yarn format:php

```

Testing
-------

[](#testing)

The PHP test suite consists of WordPress integration tests (`WP_UnitTestCase`) and runs inside the wp-env test environment.

Start the environment (first run pulls the Docker images):

```
yarn wp-env start
```

Run the tests:

```
yarn test
```

This runs PHPUnit inside the `tests-cli` container against the mounted plugin. The WordPress test library is provided by wp-env (`WP_TESTS_DIR`); PHPUnit and the PHPUnit Polyfills are installed as Composer dev dependencies, so make sure `composer install` has been run first.

Building
--------

[](#building)

Build for production:

```
yarn build
```

Watch mode for development:

```
yarn start
```

Usage
-----

[](#usage)

### Enable Primary Term for Taxonomies

[](#enable-primary-term-for-taxonomies)

Use the `achttienvijftien_primary_term_taxonomies` filter to enable primary term functionality:

```
add_filter( 'achttienvijftien_primary_term_taxonomies', function( $taxonomies ) {
    $taxonomies[] = 'category';
    $taxonomies[] = 'post_tag';
    return $taxonomies;
} );
```

### Global Functions

[](#global-functions)

All functions take the taxonomy slug first; the post ID is optional and defaults to the current post.

Check whether a post has a primary term (`bool`):

```
if ( has_primary_term( 'category', $post_id ) ) {
    // ...
}
```

Get the primary term ID (`int`, or `WP_Error` for an invalid taxonomy):

```
$term_id = get_primary_term_id( 'category', $post_id );
```

Get the primary term object (`WP_Term`, `WP_Error`, or `null` when none resolves):

```
$term = get_primary_term( 'category', $post_id );
if ( $term instanceof \WP_Term ) {
    echo esc_html( $term->name );
}
```

When no primary term is stored, these fall back to the first assigned term. Disable that fallback with the `achttienvijftien_primary_term_use_fallback` filter:

```
add_filter( 'achttienvijftien_primary_term_use_fallback', '__return_false' );
```

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance100

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b266fbc7c6022e0bd39e3e1f06d75029dda33bae8d4a109d79824cb6f3bbf18?d=identicon)[dennisenderink](/maintainers/dennisenderink)

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

![](https://www.gravatar.com/avatar/25ddb3567dc50c66226060bf3be9ea79e580f8c16852a021f2b0c007af75d06f?d=identicon)[tmdk](/maintainers/tmdk)

---

Top Contributors

[![dennisenderink](https://avatars.githubusercontent.com/u/329734?v=4)](https://github.com/dennisenderink "dennisenderink (1 commits)")[![tmdk](https://avatars.githubusercontent.com/u/690621?v=4)](https://github.com/tmdk "tmdk (1 commits)")

---

Tags

pluginwordpresstaxonomyprimary-term

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/achttienvijftien-wp-primary-term/health.svg)

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

###  Alternatives

[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.7k](/packages/afragen-git-updater)[webdevstudios/cmb2-attached-posts

Custom field for CMB2 for creating post relationships.

13465.7k](/packages/webdevstudios-cmb2-attached-posts)[iceicetimmy/acf-post-type-selector

Post type selector for Advanced Custom Fields.

559.0k](/packages/iceicetimmy-acf-post-type-selector)

PHPackages © 2026

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