Estoy tratando de verificar si mi matriz tiene publicaciones de tipo específico ‘IOS’ o no, y en base a eso, realizo algunas acciones con declaraciones if. Pero por alguna razón, no está comprobando el recuento de publicaciones, y si la matriz IOS está vacía, está tomando la matriz ‘Android’.
$args2 = array(
'post_type' => 'np_coupon_code',
'post_status' => 'publish',
'posts_per_page' => 1,
'meta_query' => array(
array(
'key' => 'np_ccode__email',
'value' => 'null',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'np_ccode__type',
'value' => array('IOS')
)
)
);
$posts_query2 = new WP_Query($args2);
$the_count_ios = $posts_query2->found_posts;
if( $the_count_ios != 0 && isset($posted_data['menu-377'])=="IOS"){
$query = new WP_Query($args2);
while ( $query->have_posts() ) : $query->the_post();
$id = get_the_ID();
$code = get_the_title();
endwhile;
if( isset($posted_data['your-email']) ){
update_post_meta($id, 'np_ccode__email', $posted_data['your-email']);
}
$to = $posted_data['your-email'];
$subject="Your PromoCode!";
$body = $code;
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
return $posted_data;
wp_reset_query();
}else{
$to = $posted_data['your-email'];
$subject="Your PromoCode!";
$body = 'No coupons left!';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
return $posted_data;
wp_reset_query();
}
.