acf/fields/taxonomy/result

Overview

This filter allows you to modify the result (text) displayed for each option in the taxonomy field.

Changelog

  • 5.0.0 – Added filter

Parameters

filter( $title, $term, $field, $post_id )
  • $title (string) the text displayed for this taxonomy term
  • $term (object) the taxonomy term object
  • $field (array) the field array containing all attributes & settings
  • $post_id (int) the current post ID being edited

Usage

There are 3 ways to hook into this filter

  1. acf/fields/taxonomy/result– filter for every field
  2. acf/fields/taxonomy/result/name={$field_name} – filter for a specific field based on it’s name
  3. acf/fields/taxonomy/result/key={$field_key} – filter for a specific field based on it’s key

functions.php

<?php

function my_post_object_result( $title, $term, $field, $post_id ) {

    // add the term's slug to each result
    $title .= '(' . $term->slug .  ')';

    return $title;

}

add_filter('acf/fields/taxonomy/result', 'my_taxonomy_result', 10, 4);

?>

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.