0

I tried this :

<?php if ( have_posts() ) : query_posts(array('orderby_last_comment' => true)); ?>

But it's not working

1 Answer 1

0

For this you can use WP_Comment_Query.

The query will be

    $comments_query_args = array(
        'post_type' => 'post',
        'number' => 5,
        'status' => 'approve'
    );
    $comments_query = new WP_Comment_Query();
    $recent_comments = $comments_query->query($comments_query_args);
4
  • Ok, but I want that for all my home page, not only the first 5 posts
    – Mathieu
    Commented Jan 8, 2014 at 21:23
  • If you remove the number argument it should work. Fo more information you can check the link which I provide in the answer.
    – user43506
    Commented Jan 8, 2014 at 22:25
  • Sorry I misunderstand a bit your question. This query will take the last comments
    – user43506
    Commented Jan 8, 2014 at 22:30
  • You have to create a custom query to be able to sort by the last commented post. You can check this topic stackoverflow.com/questions/698438/…
    – user43506
    Commented Jan 8, 2014 at 22:42

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.