Home › Forums › General Issues › acf.registerConditionType not working › Reply To: acf.registerConditionType not working
With big thanks to Elliot for helping me figure this out, and for the benefit of anyone else who finds this, the main problem was wrapping acf.Condition
in jQuery on ready.
For testing purposes, this code works and can be added to a theme’s functions.php:
add_action( 'acf/admin_footer', 'my_admin_footer' );
function my_admin_footer() {
?>
<script>
(function( $ ) {
'use strict';
var HasTerm = acf.Condition.extend({
type: 'hasTerm',
operator: '==hasTerm',
label: acf.__('Has term'),
fieldTypes: [ 'taxonomy' ],
match: function( rule, field ){
return rule.value === field.val();
},
choices: function( fieldObject ){
return '<input type="text" />';
}
});
acf.registerConditionType( HasTerm );
}( jQuery ));
</script>
<?php
}
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.