Hola, estoy haciendo un query en wordpress, que me devuelve un listado de post segun los comentarios, tengo uno que devuelve los post ordenados de mas a menos comentarios y ahora querria uno que me devolviera los post que no tienen comentarios, pero no encuentro como hacerlo.
Este es el código:
Código PHP:
$query = '';
global $options_rating;
foreach ( $options_rating['widget-pages'] as $key => $value ) {
if ( get_the_ID() == $value ) {
switch($key) {
case 'mostComment':
$query = "select ".$wpdb->prefix."posts.ID
from ".$wpdb->prefix."comments,".$wpdb->prefix."posts
where
".$wpdb->prefix."posts.ID = ".$wpdb->prefix."comments.comment_post_ID and
post_status = 'publish' and
post_type = 'post'
group by comment_post_ID order by count(comment_post_ID) DESC
limit ".$options_rating['widget-pages-limit'];
break;
case 'noComment':
$query = "select ".$wpdb->prefix."posts.ID
from ".$wpdb->prefix."comments,".$wpdb->prefix."posts
where
".$wpdb->prefix."posts.ID = ".$wpdb->prefix."comments.comment_post_ID and
post_status = 'publish' and
post_type = 'post'
group by comment_post_ID order by count(comment_post_ID)='0' DESC
limit ".$options_rating['widget-pages-limit'];
break;
}
}
}
Y esta es la parte que no me funciona
Código PHP:
case 'noComment':
$query = "select ".$wpdb->prefix."posts.ID
from ".$wpdb->prefix."comments,".$wpdb->prefix."posts
where
".$wpdb->prefix."posts.ID = ".$wpdb->prefix."comments.comment_post_ID and
post_status = 'publish' and
post_type = 'post'
group by comment_post_ID order by count(comment_post_ID)='0' DESC
limit ".$options_rating['widget-pages-limit'];
break;
¿Alguien me puede echar un cable? Muchas Gracias!