Skip to content

Instantly share code, notes, and snippets.

View albertvisuals's full-sized avatar

albertvisuals

View GitHub Profile
@MogulChris
MogulChris / custom-acf-admin.js
Last active August 7, 2023 06:25 — forked from ChrisWebbNZ/hierearchical-select-acf.php
Hierarchical select for native Advanced Custom Fields taxonomy fields.
jQuery(document).ready(function($){
//Modify select2 ajax request to include a parent_id parameter, used by custom_acf_taxonomy_hierarchy()
acf.add_filter('select2_ajax_data', function( data, args, $input, field, instance ){
var target_field_key = 'field_5c7634ca3413f'; //YOUR TARGET FIELD KEY HERE
if(data.field_key == target_field_key){
var parent_id = 0; //by default we want terms with parent of 0 (top level)