Arkadaşlar popüler yazı bileşenim tüm zamanlara ait en yüksek okunmalara göre bir listeleme yapıyor. Bu zamanı nasıl haftalık olarak ayarlayıp, haftanın popüler yazılarını gösterebilirim?
Bileşenin kodu:
<?php
/*
 * Plugin Name: Popüler Yazı
 * Version: 1.0
 */
 
add_action( 'widgets_init', 'popular_yazi' );
 
function popular_yazi() {
 register_widget( 'popular_yazi' );
}
 
class popular_yazi extends WP_Widget {
 
function popular_yazi() {

 $widget_ops = array( 'classname' => 'widget_sosyal', 'description' => __('Sağ kısım için uygundur.', 'bi3') );

 $this->WP_Widget( 'popular_yazi', __('Sağ Kısım Popüler Yazı Bileşeni', 'bi3'), $widget_ops );
 }
 
function widget( $args, $instance ) {
 
 ?>
 <?php
extract( $args );

$baslik = apply_filters('widget_title', $instance['baslik'] );
$categories = $instance['categories'];
$goster = $instance['goster'];
$tags = $instance['tags'];
		
echo $before_widget; 
if ( $baslik )
?>
			<div class="popular">
					<div class="main-baslik">
						<span class="left"><i class="fa fa-star"></i><strong>POPÜLER</strong> YAZILAR</span>
					</div>	
					<ul class="popularnews">
					<?php $popu = new WP_Query(array('showposts' => $goster , 'meta_key'=>'post_views_count','orderby'=>'meta_value_num' )); while($popu->have_posts()) : $popu->the_post();?>
						<li>
							<a href="<?php the_permalink(); ?>">
								<?php the_post_thumbnail( array(400	,355), array( 'alt' => get_the_title()) );  ?>
								<div class="popularmore">
									<h1><?php the_title(); ?></h1>
									<?php the_excerpt(); ?>
								</div>
								<div class="pbg-b"></div>
							</a>
						</li>
					<?php endwhile; ?>	
					</ul>
				</div>
 <?php
 echo $after_widget;
 }
 
function update( $new_instance, $old_instance ) {
 		$instance = $old_instance;
		$instance['baslik'] = strip_tags( $new_instance['baslik'] );
		$instance['categories'] = $new_instance['categories'];
		$instance['goster'] = strip_tags( $new_instance['goster'] );
		
		return $instance;
	}
function form( $instance ) {
  $defaults = array( 'goster' => 4);
 $instance = wp_parse_args( (array) $instance, $defaults ); ?>
 
        
        
        <p>
			<label for="<?php echo $this->get_field_id( 'goster' ); ?>">Kaç Kere Gösterilsin:</label>
			<input id="<?php echo $this->get_field_id( 'goster' ); ?>" name="<?php echo $this->get_field_name( 'goster' ); ?>" value="<?php echo $instance['goster']; ?>" style="width:100%;" />
		</p>

        
        

       
        
         
    

	<?php
	}
 
 }

 
?>