WordPress implementation of the thermal evaluation of the article (within a certain time, the specified directory)

Source: Internet
Author: User
Want to implement a WordPress thermal evaluation of the article (a certain period of time, the specified directory) function, do not want to use plug-ins, from the Internet for a long time, and finally achieve 2/3, why so to say, because according to the amount of comments and a certain period of time the two have been implemented, but the designated directory this has not been realized.

Code paste, this code is written in the WP template function.php inside.

function popularposts_with_comment($posts_num=10,$days=7,$display=ture) {global $wpdb,$post; $output = '';      $most_comment = $wpdb->get_results("    SELECT ID , post_title , comment_count     FROM $wpdb->posts     WHERE post_type = 'post' AND TO_DAYS(now()) - TO_DAYS(post_date) < $days     ORDER BY comment_count DESC LIMIT 0 , $posts_num ");    foreach ($most_comment as $post) {        $post_title = get_the_title();        $post_views = getPostViews($postID);        $output .= '
  • '.get_the_post_thumbnail().''. '

    '.$post_title. '

    浏览次数:'.getPostViews(get_the_ID()).'

  • '; } echo $output;

    }

    Reply content:

    Want to implement a WordPress thermal evaluation of the article (a certain period of time, the specified directory) function, do not want to use plug-ins, from the Internet for a long time, and finally achieve 2/3, why so to say, because according to the amount of comments and a certain period of time the two have been implemented, but the designated directory this has not been realized.

    Code paste, this code is written in the WP template function.php inside.

    function popularposts_with_comment($posts_num=10,$days=7,$display=ture) {global $wpdb,$post; $output = '';      $most_comment = $wpdb->get_results("    SELECT ID , post_title , comment_count     FROM $wpdb->posts     WHERE post_type = 'post' AND TO_DAYS(now()) - TO_DAYS(post_date) < $days     ORDER BY comment_count DESC LIMIT 0 , $posts_num ");    foreach ($most_comment as $post) {        $post_title = get_the_title();        $post_views = getPostViews($postID);        $output .= '
  • '.get_the_post_thumbnail().''. '

    '.$post_title. '

    浏览次数:'.getPostViews(get_the_ID()).'

  • '; } echo $output;

    }

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.