Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2. }
  3.  
  4.  
  5. function gen21_display_most_viewed_posts($smallthumbs = true) {
  6.  
  7. global $wpdb;
  8. /* taken from wp-postviews.php by Lester Chan http://lesterchan.net/portfolio/programming/php/ */
  9. $favourites = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND post_type = 'post' AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT 4");
  10.  
  11. if (!$favourites) return false;
  12.  
  13. foreach ($favourites as $fav) { ?>
  14. <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 item">
  15. <a class="front-item" href="<?php echo get_permalink($fav); ?>">
  16. <?php
  17.  
  18. echo get_the_post_thumbnail($fav, 'thumbnail');
  19. /*
  20. if ($smallthumbs) {
  21. echo get_the_post_thumbnail($fav, 'small');
  22. } elseif ( has_post_thumbnail($fav) ) {
  23. if (rand(0,1) == 1) {
  24. echo get_the_post_thumbnail($fav, "medium");
  25. }
  26. else {
  27. echo get_the_post_thumbnail($fav, "small");
  28. }
  29. } */ ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement