• Resolved jason1974

    (@jason1974)


    Small tweak request.
    If I want to show the most viewed posts in the past week. But I am displaying the number of comments and I think it should really just show the total number of comments. When the user doesn’t know the length of time specified, I think the assumption is that it’s showing the total number of comments on a post.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there!

    The only way you could achieve this at this time is by hooking into the wpp_post filter to include the total comments count using the get_comments_number() function.

    For example:

    function custom_popular_post( $post_html, $p, $instance ){  
      
        $output = '<li><a href="' . get_the_permalink( $p->id ) . '" class="wpp-post-title" title="' . esc_attr( $p->title ) . '">' . $p->title . '</a> <span class="post-stats">' . get_comments_number( $p->id ) . ' comments so far</span></li>';
    
        return $output;
    
    }
    add_filter( 'wpp_post', 'custom_popular_post', 10, 3 );
    Thread Starter jason1974

    (@jason1974)

    cool! where would that goes into functions.php?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Yep, that needs to be placed either somewhere inside your theme’s functions.php file or in a standalone plugin (if you know how to :P).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Number of comments’ is closed to new replies.