wwwha 36 ارسال شده در اسفند 20، 1395 گزارش اشتراک گذاری ارسال شده در اسفند 20، 1395 سلام خدمت کاربران عزیز ممنون میشم راهنمایی کنید کد نمایش نمایش تعداد بازدید مطالبم که در فانکشن قرار دادم اینه : // function to display number of posts. function getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' '; } // function to count views. function setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } // Add it to a column in WP-Admin add_filter('manage_posts_columns', 'posts_column_views'); add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2); function posts_column_views($defaults){ $defaults['post_views'] = __(''); return $defaults; } function posts_custom_column_views($column_name, $id){ if($column_name === 'post_views'){ echo getPostViews(get_the_ID()); } } سه تا تب ایجاد کردم مطالب پربازدید روز / هفته / ماه عزیزی هست که حلقه فراخوانی مطالب پربازدید روز ، هفته ، ماه رو بصورت جداگانه اینجا ارسال کنه مطمئنا به درد خیلی ها میخوره * نکته : با افزونه نمیخوام بزنم ، کدش رو میخوام تشکر لینک به دیدگاه به اشتراک گذاری در سایت های دیگر More sharing options...
KINGERFAN 406 ارسال شده در اسفند 20، 1395 گزارش اشتراک گذاری ارسال شده در اسفند 20، 1395 سلام برای ماه <ul> <?php $month = date('m'); $year = date('Y'); query_posts('post_type=post&posts_per_page=10&orderby=comment_count&order=DESC&year=' . $year . '&monthnum=' . $month); while (have_posts()): the_post(); ?> <li><a href="https://go.20script.ir/index.php?url=<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li> <?php endwhile; wp_reset_query(); ?> </ul> برای هفته <ul> <?php $week = date('W'); $year = date('Y'); query_posts('post_type=post&posts_per_page=10&orderby=comment_count&order=DESC&year=' . $year . '&w=' . $week); while (have_posts()): the_post(); ?> <li><a href="https://go.20script.ir/index.php?url=<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li> <?php endwhile; wp_reset_query(); ?> </ul> برای روز <?php $popularpost = new WP_Query( array( 'posts_per_page' => 4, 'meta_key' => 'post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); while ( $popularpost->have_posts() ) : $popularpost->the_post(); the_title(); endwhile; ?> لینک به دیدگاه به اشتراک گذاری در سایت های دیگر More sharing options...
پست های پیشنهاد شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.