I have a custom taxonomy called "tasks" shared between two custom post types of "roles" and "products".
Expected results: I need to count how many times a given "task" term is used for each "role" post type minus the count shared by a "product" post type using the same "task" term.
Actual results: None to report as I don't know how to tackle this
Error messages: None
What I've tried: Google keeps coming back with how to count the post type, not the terms :(
The code below is my plan B. Here I am just doing some micro loops on each post-type (only one shown below for brevity), getting the tasks and turning them into an associative array via array_count_values
$taskList = [];
$queryRoles = new WP_Query( array(
"post_type" => "roles"
));
while ( $queryRoles->have_posts() ) : $queryRoles->the_post();
$tasks = get_the_terms( get_the_ID(), "tasks" );
foreach ( $tasks as $task ) :
$taskList[] = $task->name;
endforeach;
endwhile;
$overlappingRoleTasks = $taskList;
print_r(array_count_values($taskList));