Answers for "wp graphql add filter acf"

PHP
0

wp graphql add filter acf

add_filter('graphql_post_object_connection_query_args', function ($query_args, $source, $args, $context, $info) {

    $post_object_id = $args['where']['postObjectId'];

    if (isset($post_object_id)) {
        $query_args['meta_query'] = [
            [
                'key' => 'myCustomField',
                'value' => $post_object_id,
                'compare' => '='
            ]
        ];
    }

    return $query_args;
}, 10, 5);
Posted by: Guest on July-08-2020

Browse Popular Code Answers by Language