LOS MAS VISTOS,功能WORDPRESS
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LOS MAS VISTOS,功能WORDPRESS相关的知识,希望对你有一定的参考价值。
Funcion los post más vistos en wordpress.
function get_most_viewed($mode = '', $limit = 10, $chars = 0, $display = true) { global $wpdb; $views_options = get_option('views_options'); $where = ''; $temp = ''; $output = ''; $where = "post_type = '$mode'"; } else { $where = '1=1'; } $most_viewed = $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 $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit"); if($most_viewed) { foreach ($most_viewed as $post) { $post_title = get_the_title($post); if($chars > 0) { $post_title = snippet_text($post_title, $chars); } $post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password, $chars); $output .= $temp; } } else { $output = '<li>'.__('N/A', 'wp-postviews').'</li>'." "; } if($display) { echo $output; } else { return $output; } }
以上是关于LOS MAS VISTOS,功能WORDPRESS的主要内容,如果未能解决你的问题,请参考以下文章