Beaver Builder Child Theme

3rd Party Logical Operators

Estimated reading: 2 minutes

If you’ve added 3rd party fieldtypes to the Toolbox Post Fields, it is providing you with all available logical operators. Sometimes a limited selection is easier to use, so by setting the operators per fieldtype you can limit them.

You can do this by adding a custom filter to your theme’s functions.php:


add_filter( 'toolbox_condlogic_operators', 'foo123_add_custom_fieldtype_operator' , 10, 1 );

function foo123_add_custom_fieldtype_operator( $fieldtypes ) {
    return array_merge( $fieldtypes ,
                            'image_aspect_ratio_crop' =>   array(
                                        'operators' => [ 'equals', 'does_not_equal' , 'is_empty', 'is_not_empty', 'is_set' , 'is_not_set' ],
                                        'hasvalue' => true,
                                        'hasend' => false,

Remember to merge the new fieldtype’s array with the already existing fieldtypes. The settings for the fieldtype (here: ‘image_aspect_ratio_crop’) take 3 parameters:

  • operators, the operators that are available for this fieldtype
  • hasvalue, whether a inputbox for a value needs to be present
  • hasend, whether an endvalue needs to be present

hasvalue and hasend parameter

Depending on the operators, you will be setting the hasvalue and hasend parameter. The ‘equals’ operator for instance will need the hasvalue parameter to be set to true, this way showing an input field so that a value to compare to can be entered. If none of the operators require a second input field you can set the hasend parameter to false.

Examples of operators that DO need the hasend parameter to be set to true, are ‘between’, ‘not_between’, ‘within’, ‘not_within’. This will allow a second input field to show when this operator is selected.

Share this Doc

3rd Party Logical Operators

Or copy link