Support

Account

Home Forums General Issues relationship_query and Taxonomy

Unread

relationship_query and Taxonomy

  • Hi,

    I use to use this function to apply a custom filter to a relation field ‘cxcpt_client_user’:

    function my_relationship_query( $args, $field, $post_id ) { 
    	$args = array(
    	'order'          => 'ASC',
    	'orderby'        => 'display_name',
    	        'meta_query' => array(
                array(
                    'key' => 'cxcpt_user_client',
                    'value' =>  '',
                    'compare' => '=',
               	 	),
            	),
    	    );    
        return $args;  
    }
    add_filter('acf/fields/user/query/name=cxcpt_client_user', 'my_relationship_query', 10, 3);

    The relation field is located into a custom Taxonomy and is linked with the User list: it only generates user which has no value into the field ‘cxcpt_user_client’.

    The problem is that the relation field is always empty. Why ? I guess that is because the post_id used by the function ‘my_relationship_query( $args, $field, $post_id )’ is formated like: ‘term_54′ instead of ’54’ because it provides from a TAXONOMY (not as usual: a POST).

    Is there any way to fix it?

    thanks

Viewing 1 post (of 1 total)

The topic ‘relationship_query and Taxonomy’ is closed to new replies.