Contexts / Term Context

Read More: Fieldmanager_Context_Term

Adds fields to the new and/or edit term screen, and saves data to term meta.

Term meta didn’t exist in core by default until WordPress 4.4, so this was handled in an optimal way by Fieldmanager behind-the-scenes. As of WordPress 4.4, Fieldmanager can use core’s term meta to store data for this context. If you need to migrate Fieldmanager term meta to core term meta, see https://github.com/alleyinteractive/fieldmanager-term-meta-migration.

Action

fm_term_{taxonomy}

Additional References

Fieldmanager_Field::add_term_meta_box() (WordPress 4.4+)
Fieldmanager_Field::add_term_form() (Deprecated; WordPress < 4.4)

  1. Example 1: Basic Term Field (WordPress 4.4+)

    Note that in this example, we're hooking into the action fm_term_category, because we're adding fields to the category taxonomy. If we were adding fields to tags, we would use fm_term_post_tag and the second argument we'd pass to add_term_meta_box() would be 'post_tag'. Similarly, If we were adding fields to a custom taxonomy, e.g. event-type, we would hook into fm_term_event-type and pass 'event-type' as the second argument to add_term_meta_box().

    add_action( 'fm_term_category', function() {
    	$fm = new Fieldmanager_TextField( array(
    		'name' => 'demo',
    	) );
    	$fm->add_term_meta_box( 'Basic Field', 'category' );
    } );
  2. Example 2: Basic Term Field (WordPress < 4.4)

    This example is exactly like the previous, except that we're using Fieldmanager_Field::add_term_form() to declare the field's context. This method is now deprecated, but it will use Fieldmanager's custom term meta instead of Core's term meta. You would only want to do this if you were using a version of WordPress prior to 4.4.

    add_action( 'fm_term_category', function() {
    	$fm = new Fieldmanager_TextField( array(
    		'name' => 'demo',
    	) );
    	$fm->add_term_form( 'Basic Field', 'category' );
    } );