Listar post sin comentarios

  • Autor Autor MaxS
  • Fecha de inicio Fecha de inicio
MaxS

MaxS

Gamma
Verificación en dos pasos activada
Hola muchachos, requiero de su ayuda 🙂

El problema es que quiero listar los post por cantidad de comentarios.
Listar todos los post que no tengan comentarios. Si tienen comentarios, que no se listen..
Traté con Tags/get posts.. pero solo ordena por cantidad de comentarios.. 🙁
 
Hola muchachos, requiero de su ayuda 🙂

El problema es que quiero listar los post por cantidad de comentarios.
Listar todos los post que no tengan comentarios. Si tienen comentarios, que no se listen..
Traté con Tags/get posts.. pero solo ordena por cantidad de comentarios.. 🙁

PHP:
add_filter( 'posts_where', 'filter_where' );
$query = new WP_Query($args);
remove_filter( 'posts_where', 'filter_where' );

function filter_where( $where = '' ) {
    $where .= " AND comment_count = 0 ";
    return $where;
}

posts - wp_query select if have comments - WordPress Answers
google: wp_query + post with comments + wp

el ejemplo del sitio muestra post que tengan comentarios, solo cambie el > por = asi solo muestra los que no tienen comentarios.
 
PHP:
add_filter( 'posts_where', 'filter_where' );
$query = new WP_Query($args);
remove_filter( 'posts_where', 'filter_where' );

function filter_where( $where = '' ) {
    $where .= " AND comment_count = 0 ";
    return $where;
}

posts - wp_query select if have comments - WordPress Answers
google: wp_query + post with comments + wp

el ejemplo del sitio muestra post que tengan comentarios, solo cambie el > por = asi solo muestra los que no tienen comentarios.


Como siempre.. cicklow puntual con las respuestas.

Gracias 🙂

---------- Post agregado el 20-feb-2014 hora: 23:50 ----------

Intente implementarlo y no me funciona.

Intenté con este y me funcionó.. por si a alguien le sirve:

PHP:
function filter_comment_count( $sql ){
    global $wpdb;
    $comment_count = get_query_var( 'comment_count' );

    if( is_numeric($comment_count) )
        $sql .= $wpdb->prepare( " AND {$wpdb->posts}.comment_count = %d ", $comment_count );

    return $sql;
}

PHP:
add_filter( 'posts_where', 'filter_comment_count'  );
query_posts( 'comment_count=0' );
remove_filter( 'posts_where', 'filter_comment_count' );

Pero demora un poco, habrá alguna manera de acelerarlo?
 
Atrás
Arriba