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;
}