WordPress.org

Ready to get started?Download WordPress

Forums

Using get_posts() function to load the three most commented posts (3 posts)

  1. ido_doron
    Member
    Posted 2 years ago #

    Is there any way to use get_posts() function to load the three most commented posts?
    Because I used this function to load the three most recent posts by this code:

    [...]
    $args = array( 'numberposts' => 3, 'orderby' => 'post_date', 'order' => 'DESC' );
    $myposts = get_posts( $args );
    [...]

    It worked. It loaded the three most recent posts, but when I tried to change the “orderby” from ‘post_date’ to ‘comment_count’, only one post was loaded.
    Is there any solution for this issue which doesn’t mean to use other function such as wp_query() or query_posts()?

  2. ido_doron
    Member
    Posted 2 years ago #

    Does anyone knows how to solve the problem?

  3. paulschreiber
    Member
    Posted 2 years ago #

    Order by comment_count:
    $args = array( 'numberposts' => 3, 'orderby' => 'comment_count', 'order' => 'DESC' );

Topic Closed

This topic has been closed to new replies.

About this Topic