Home Forums General Issues ACF filter over a custom taxonomy


ACF filter over a custom taxonomy

  • I’m using wp api v2. I registered my custom taxonomy in this way:

    function artist_init() {
                'label' => __( 'Artists' ),
                'rewrite' => array( 'slug' => 'artists' ),
                'show_admin_column' => true,
                'hierarchical' => false,
                'show_in_rest' => true
    add_action( 'init', 'artist_init' ); 

    And I’m able to get it through:

    GET /wp-json/wp/v2/artists
    I then added through advanced custom field a new meta (“topartist”) and I’m able to see it in the taxonomies:

        "id": 3674,
        "count": 5,
        "description": "provaprova",
        "link": ".../artists/paperwhite/",
        "name": "paperwhite",
        "slug": "paperwhite",
        "taxonomy": "artists",
        "meta": Array[0][
        "acf": {
          "topartist": "1"

    I would like now to filter on this new meta over all my taxonomy. So I added this in the function.php:

    function my_allow_meta_query( $valid_vars ) {
        $valid_vars = array_merge( $valid_vars, array( 'meta_key', 'meta_value' ) );
        return $valid_vars;
    add_filter( 'rest_query_vars', 'my_allow_meta_query' );

    and tryed:

    GET /wp-json/wp/v2/artists?filter[meta_key]=topartist

    But the filter is not working. I’m able to filter over all the posts, but I’m not able to filter over taxonomies. I’m missing something?

Viewing 1 post (of 1 total)

The topic ‘ACF filter over a custom taxonomy’ is closed to new replies.