Documentation - How To - Filter – Sort Interface – Create a new Sort Conditional

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInPrint this page

Filter – Sort Interface – Create a new Sort Conditional

Additional conditionals can be created using the apto_conditionals_add filter.

Examples:

add_action('apto_conditionals_add', 'custom_apto_conditionals_add');
    function custom_apto_conditionals_add($APTO_conditionals)
        {
            $APTO_conditionals->add_rule(array(
	                        'id'                    =>  'my_custom',
 	                   'title'                 =>  'Is Custom Criteria',
                                            'admin_html'            =>  'conditional_rule_custom_admin_html',
                                            'query_check_callback'  =>  'conditional_rule_custom_query_check',
                                            'comparison'            =>  array('IS', 'IS NOT', 'CONTAIN')
                                            ));      
        }
        
    function conditional_rule_custom_admin_html($options)
        {
            $html = '<input type="text" name="conditional_rules['.$options['group_id'].']['.$options['row_id'].'][conditional_value]" class="text" value="">';
                                
            return $html;   
        }
    function conditional_rule_custom_admin_save()
        {
           //additional code when conditional save   
            return TRUE;
        }
    function conditional_rule_custom_query_check()
        {
         	//this will check on front side   
            return TRUE;   
        }

*This code should be used within the theme or a custom plugin.