Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

mcaskill/acf-field-taxonomy-selector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ACF Taxonomy Selector Field

  • Requires at least: 3.4
  • Tested up to: 5.3
  • Stable tag: 1.0

The Taxonomy Selector field allows the selection of one or more taxonomies.

Description

Provides a new field type, for the Advanced Custom Fields WordPress plugin, which allows users to select of one or more taxonomies.

The field is based on Tim Perry's Post Type Selector field type.

Compatibility

This ACF field type is compatible with:

  • ACF 5
  • ACF 4
  • ACF 3

Installation

The field type can be used as plugin, must-use plugin, a Composer package, and a theme include.

Via Composer

$ composer require mcaskill/acf-field-taxonomy-selector

Via WordPress Admin Panel

  1. Download the latest ZIP of this repo.
  2. In your WordPress admin panel, navigate to PluginsAdd New.
  3. Click Upload Plugin.
  4. Upload the ZIP file that you downloaded.

Activation

Then activate the plugin via wp-cli.

$ wp plugin activate acf-field-taxonomy-selector

Or through the WordPress admin panel (PluginsACF Taxonomy SelectorActivate).

Via Theme

  1. Download the latest ZIP of this repo.

  2. Extract the plugin from the ZIP file you downloaded.

  3. Upload the directory into your theme's directory.

  4. Edit your theme's functions.php file to include the plugin's main PHP file:

    add_action( 'acf/register_fields', 'register_my_acf_fields' );
    
    function register_my_acf_fields()
    {
        include_once '{acf-taxonomy-selector}/acf-taxonomy-selector.php';
    }

Usage

Get Field Value

$taxonomy_name   = get_field('taxonomy');
$taxonomy_object = get_taxonomy( $taxonomy_name );

echo '<h2>' . $taxonomy_object->label . '</h2>';

$terms = get_terms( $taxonomy_name );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
    echo '<ul>';
    foreach ( $terms as $term ) {
        echo '<li>' . $term->name . '</li>';
    }
    echo '</ul>';
}

Changelog

0.1.0

  • Initial Release

About

Taxonomy selector field type for Advanced Custom Fields

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages