Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
    
To show code from something like a page template please use pastebin or another code pasting service. –  Rachel Baker Aug 2 '12 at 1:09
    
@RachelBaker A question should be understandable without any external resource. –  toscho Aug 2 '12 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. –  Rachel Baker Aug 2 '12 at 15:15

1 Answer 1

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()

share|improve this answer
    
Um...okay, so how can I get it to restrict posts without comments? –  Ben Aug 2 '12 at 23:10
    
just like in the code i showed you. relevant code: if( get_comments_number() ) the_post(); –  peteroak Aug 3 '12 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 Aug 3 '12 at 3:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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