Count post type of Pods entity
-
I have custom post type
Task
where I assigned Users as Volunteers.https://i.stack.imgur.com/Yqnum.png
Now I would like to fetch
how many tasks assigned to a Volunteer.
I am using below code.
$users = new WP_User_Query(array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'last_name', 'value' => $_POST['search'], 'compare' => 'LIKE', ), ), )); $users_found = $users->get_results(); $names = array(); foreach ($users_found as $user) { $this_users_tasks = get_user_meta($user->ID,'task',false); $names[$user->ID] = $user->display_name.' ('.count($this_users_tasks).')'; } echo json_encode($names); die;
But I am getting wrong result.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Count post type of Pods entity’ is closed to new replies.