Home Forums General Issues Taxonomy term meta


Taxonomy term meta

  • So I have created a custom taxonomy, “Firms”.
    As you know, each term has default meta of “Name”, “Slug” and “Description”.

    But I want to extend this with additional fields. In other words, I believe I want to *add custom term meta*.

    Now, I could look in to the technical way of doing this, which I believe is the following functions, introduced a year ago…

    – add_term_meta()
    – update_term_meta()
    – delete_term_meta()
    – get_term_meta()

    However, am I right in thinking that adding an ACF field group to appear when Taxonomy Term equals my “firm” would produce the same effect?

    I have tested this and, indeed, I can successfully add new fields to my Edit Term pages.

    But are the metadata saved as they would be as if I used those functions natively?

    I am expecting the answer is: “Yes”.

    The one thing I’d add is, on the Edit Term page, the background grey in the form-table is darker than the grey page background itself.


  • Actually, right now the answer in No. ACF does not save field added to a term in the term meta table at the moment. They are saved in the options table. This question has been asked many times. The developer is working on it and the transition from options to term_meta will be included in ACF 5.5 and it will be backwards compatible. There are temporary solutions that can be used here

  • Well I guess I’m just going to have to mess up my options table until then.

    5.5… should be… by year’s end… ?

    Thanks for the reply.

  • The last I heard Elliot was hoping to release 5.5 next month, yes, but yes, it should be out I hope by the end of the year.

  • I have unpicked the ACF field group I had planned to use for this, pending the 5.5 release.
    I wanted to get it going in the meantime by writing in manual functions that work directly with term meta.
    But I finding it very hard going, understanding how to do this.

    Does anyone know a workaround, a way to display, save to and read from extended meta boxes on term pages, that does work directly with term meta, not options?


  • I don’t, I I were going to do this I would do something like

    add_action('init', 'filters_for_acf_term_meta');
    function filters_for_acf_term_meta() {
      $acf_version = acf_get_setting('version');
      if( version_compare($acf_version, '5.5.0, '>=') ) {
        // 5.5 uses term meta, don't need the filters
      // add filters and functions to deal with term meta
      // you can create more than one here and they
      // will only be loaded if ACF <5.5
      add_action('acf/save_post', 'convert_options_to_term_meta');
      function convert_options_to_term_meta($post_id) {
        // use examples from 
        // to build actions
      } // end function convert_options_to_term_meta
    } // end function filters_for_acf_term_meta

    The code was edited to correct error

  • Thanks, John.
    I understand the code… until we get to 5.5, capture ACF fields from options, copy them to term meta and destroy the versions in options, I guess.

    But I think implementing is beyond my skillset.
    So maybe I will just reinstate the field group in readiness for 5.5.

  • ACF will move all of the values from options to term meta during the update to 5.5, if that helps you at all.

  • John,
    That sounds very clever. It will move them over and wipe traces from options?
    That would indeed convince me to just run with the field group form now.


  • It does not look like it’s removing the values from the options table. It may have something to do with not breaking sites. Some people may actually be using get_option() to get the values instead of get_field(). I don’t know that this is the case, but it may be why ACF is not automatically removing them. People would not be pleased if they updated the site and large portions of it stopped working.

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘Taxonomy term meta’ is closed to new replies.