0

I'm trying to make a page that will show only the posts that have comments. I have this in my page template:

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( 'cat=-8378, -13444&orderby=comment_count&paged=' . $paged );
while (have_posts()) : the_post();
?>

But it's not working. It still just shows my normal post display. Any suggestions?

Thanks!

3
  • To show code from something like a page template please use pastebin or another code pasting service. Commented Aug 2, 2012 at 1:09
  • @RachelBaker A question should be understandable without any external resource.
    – fuxia
    Commented Aug 2, 2012 at 2:31
  • @tosco When I first viewed the post the code snippet was not there at all. I assumed he was pasting in the entire page template. Commented Aug 2, 2012 at 15:15

1 Answer 1

0

your query doesn't restrict posts without comments.

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts( 'cat=-8378, -13444&orderby=comment_count&paged=' . $paged );
    while (have_posts()) : 
      if(  get_comments_number() ) the_post();

   [...]

reference: get_comments_number()

3
  • Um...okay, so how can I get it to restrict posts without comments?
    – Ben
    Commented Aug 2, 2012 at 23:10
  • just like in the code i showed you. relevant code: if( get_comments_number() ) the_post();
    – pcarvalho
    Commented Aug 3, 2012 at 0:52
  • Oh, I'm sorry, stupid me. I misread that code as simply a quote of mine. Thanks, I'll give it a try!
    – Ben
    Commented Aug 3, 2012 at 3:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.