Support

Account

Home Forums Backend Issues (wp-admin) Filter Taxonomy Field by Custom Field

Solving

Filter Taxonomy Field by Custom Field

  • I have a taxonomy field for Categories and have added a custom field to the category called “Premium”. I would like my category ACF field to just show the Premium categories. I’m not sure how to approach that. I don’t see a way to filter the category in the taxonomy field.

    Thanks in advance.

  • Totally figured it out. I had the field displaying as checkboxes. It would be nice to have the checkbox be an option. The multi-select is a bit of a clunky option.

  • My solution in case someone wants an example:

    // FILTER FOR PREMIUM CONTENT FOR COMPANIES
    
    add_filter('acf/fields/taxonomy/query', 'moxie_acf_company_premium', 10, 3);
    function moxie_acf_company_premium( $args, $field, $post_id ) {
    	
    	$args['taxonomy'] = 'category';
    	
        $args['meta-query'] = array(
    		array (
    			'key'		=> 'premium',
    			'value'		=> 'yes',
    		)
    	);
    
        return $args;
    }
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.