Home › Forums › ACF PRO › Taxonomy field – multiple taxonomies › Reply To: Taxonomy field – multiple taxonomies
Ended up changing the taxonomy field (taxonomy.php):
Lines 115-134:
$args = apply_filters('acf/fields/taxonomy/query', $args, $field, $options['post_id']);
$args = apply_filters('acf/fields/taxonomy/query/name=' . $field['name'], $args, $field, $options['post_id'] );
$args = apply_filters('acf/fields/taxonomy/query/key=' . $field['key'], $args, $field, $options['post_id'] );
// get terms
$terms = get_terms( $field['taxonomy'], $args );
// sort into hierachial order!
if( is_taxonomy_hierarchical( $field['taxonomy'] ) ) {
// this will fail if a search has taken place because parents wont exist
if( empty($args['search']) ) {
$terms = _get_term_children( 0, $terms, $field['taxonomy'] );
}
}
Replaced with:
$all_taxonomies = get_taxonomies();
$taxonomies = array();
foreach ($all_taxonomies as $taxonomy) {
if ($taxonomy != 'post_tag' && $taxonomy != 'nav_menu' && $taxonomy != 'link_category' && $taxonomy != 'post_format') {
array_push($taxonomies, $taxonomy);
}
}
$args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false);
$terms = get_terms($taxonomies, $args);
And Line 489:
$terms = $this->get_terms( $field['value'], $field['taxonomy'] );
Replaced with:
$all_taxonomies = get_taxonomies();
$taxonomies = array();
foreach ($all_taxonomies as $taxonomy) {
if ($taxonomy != 'post_tag' && $taxonomy != 'nav_menu' && $taxonomy != 'link_category' && $taxonomy != 'post_format') {
array_push($taxonomies, $taxonomy);
}
}
$args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false);
$terms = get_terms($taxonomies, $args);
The following will output all terms from the ‘category’ taxonomy and from all other registered taxonomies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.