SHARE
TWEET

Untitled

a guest Sep 29th, 2016 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div class="widget listing_articole widget_top_articole">
  2.     <h4 class="widget-title">Top articole</h4>
  3.     <span class="cand">7 zile</span>
  4.     <?php
  5.  
  6.     function filter_where($where = '') {
  7.         $where .= " AND post_date > '" . date('Y-m-d', strtotime('- 7 days')) . "'";
  8.         return $where;
  9.     }
  10.  
  11.     add_filter('posts_where', 'filter_where');
  12.     if (false === ( $toparticole = get_transient('widget_tp') )) {
  13.         $toparticole = new WP_Query(array(
  14.             'ignore_sticky_posts' => 1,
  15.             'post_status' => 'publish',
  16.             'posts_per_page' => 5,
  17.             'orderby' => 'comment_count',
  18.             'order' => 'DESC',
  19.         ));
  20.         set_transient('widget_tp', $toparticole, 1 * HOUR_IN_SECONDS);
  21.     }
  22.     ?>
  23.  
  24.     <ul class="widget-articole">
  25.         <?php while ($toparticole->have_posts()) : $toparticole->the_post(); ?>
  26.             <?php
  27.             static $position;
  28.             $position ++;
  29.             ?>
  30.             <li class="post-<?php the_ID(); ?>">  
  31.                 <?php if (has_post_thumbnail()) { ?>
  32.                     <div class="post-photo">
  33.                         <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
  34.                             <?php the_post_thumbnail('small-thumb'); ?>
  35.                         </a>                      
  36.                     </div>
  37.                 <?php } else { ?>
  38.                     <div class="post-photo">
  39.                         <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
  40.                             <img width="60" height="60" alt="<?php the_title_attribute(); ?>" src="<?php echo get_stylesheet_directory_uri(); ?>/images/noimg.png" />
  41.                         </a>
  42.                     </div>
  43.                 <?php } ?>
  44.                 <div class="post-description">
  45.                     <h5 class="title"><a href="<?php esc_url(the_permalink()); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>
  46.                     <p class="widget-time"><?php the_time('j F Y') ?></p>
  47.                 </div>
  48.                  <span class="pozitie">#<?php echo $position; ?></span>
  49.             </li>
  50.             <?php
  51.         endwhile;
  52.         wp_reset_query();
  53.         remove_filter('posts_where', 'filter_where');
  54.         ?>            
  55.     </ul>
  56. </div>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top