WP Manifestindependent plugin directory
manifest / content / wp-primary-term

WP Primary term

Lightweight WordPress plugin that adds a primary term selector to any taxonomy. Opt in per taxonomy via filter, pick the primary term right in the Gutenberg editor, and read it back with has_primary_term(), get_primary_term_id(), and get_primary_term(), with automatic fallback to the first assigned term.

by 1815 · github.com/achttienvijftien/wp-primary-term · website

0stars
2.5kcomposer installs
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/achttienvijftien/wp-primary-term/archive/refs/heads/main.zip

Also on Packagist as achttienvijftien/wp-primary-term:

composer require achttienvijftien/wp-primary-term

From the readme

WP Primary Term Primary term selector for WordPress taxonomies. Installation (Development) Install PHP dependencies: Install JavaScript dependencies: Lint Format code: Testing The PHP test suite consists of WordPress integration tests (WPUnitTestCase) and runs inside the wp-env test environment. Start the environment (first run pulls the Docker images): Run the tests: This runs PHPUnit inside the tests-cli container against the mounted plugin. The WordPress test library is provided by wp-env (WPTESTSDIR); PHPUnit and the PHPUnit Polyfills are installed as Composer dev dependencies, so make sure composer install has been run first. Building Build for production: Watch mode for development: Usage Enable Primary Term for Taxonomies Use the achttienvijftienprimarytermtaxonomies filter to enable primary term functionality: 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): Get the primary term ID (int, or WPError for an invalid taxonomy): Get the primary term object (WPTerm, WPError, or null when none resolves): When no primary term is stored, these

Read the full README on GitHub →