I have written WP_Query where I want to show custom posts list 'messages' by comparing a meta_key with an array of values(courses like either 100 or 100,200 depends on how user registered). Initially users like trainer or trainee registers to either single course(ex: 100) or multiple courses(ex: 100,200). My code is working fine for the user who registers to single course but for users who registers to multiple courses(100,200) it is showing the notifications(messages) with either 100 or 200 not showing the notifications(messages) with both the courses(100,200). like below is my code:
$the_query = new WP_Query(array( 'post_type' => 'messages', 'meta_query' => array ( 'relation' => 'AND', array ( 'key' => 'course', 'value' => $course_only_ids, 'compare' => 'IN' ), array ( array ( 'key' => 'inistitute_name', 'value' => array ($institute_name), 'compare' => 'IN' ) ) ), 'posts_per_page' => '5', 'paged' =>$paged, 'post_status' => $status, 'order' => 'DESC' ));
If I print_r($course_only_ids) then the array like below:
Array (  => 2031  => 1919 )
my meta_key 'course' is stored as a string like this 2031,300,1919 for each custom post called 'course'. I want to display notifications(messages) of both registered courses that matches with either single meta_value or both meta values. Can anyone please tell me what's wrong in the code? Thanks in advance.