Now, first go here: bandeq(DOT)com/taiwan/
The area where it says 'Popular this month', is currently not showing anything although it is supposed to show the posts with the most views. It was working fine before - untill I updated the plugin to post view PLUS. Now it just shows N/A as the output.
Here is the code for the sidebar
<li>
<h3 class="sidebartitle"><?php _e('Popular This Month'); ?></h3>
<?php if(function_exists('get_most_viewed')): ?>
<ul> <?php get_most_viewed(); ?></ul>
<?php endif; ?> </li>
</ul>
</div>
<?php endif; ?>
</div>
<!--/sidebar -->
And here is the code for the function
// Function: Display Most Viewed Page/Post
if( !function_exists('get_most_viewed') ) {
function get_most_viewed($mode='', $limit=10, $chars=0, $display=true, $with_bot=true) {
global $wpdb, $post;
$output_format = get_settings('PV+_option');
if( $mode=='post' ) {
$where = "p.post_type = 'post'";
} elseif( $mode=='page' ) {
$where = "p.post_type = 'page'";
} else {
$where = "(p.post_type = 'post' OR p.post_type = 'page')";
}
if( $with_bot ) {
$most_viewed = $wpdb->get_results("SELECT p.ID, p.post_title, p.post_name, p.post_status, p.post_date, (CAST(pm1.meta_value AS UNSIGNED) + CAST(pm2.meta_value AS UNSIGNED)) AS views FROM ".$wpdb->posts." AS p LEFT JOIN ".$wpdb->postmeta." AS pm1 ON pm1.post_id = p.ID LEFT JOIN ".$wpdb->postmeta." AS pm2 ON pm2.post_id = p.ID WHERE p.post_date < '".current_time('mysql')."' AND p.post_status = 'publish' AND ".$where." AND pm1.meta_key = 'views' AND pm2.meta_key = 'bot_views' AND p.post_password = '' ORDER BY views DESC LIMIT ".$limit);
$output_format = $output_format['mostviewsbot'];
} else {
$most_viewed = $wpdb->get_results("SELECT p.ID, p.post_title, p.post_name, p.post_status, p.post_date, CAST(pm.meta_value AS UNSIGNED) AS views FROM ".$wpdb->posts." AS p LEFT JOIN ".$wpdb->postmeta." AS pm ON pm.post_id = p.ID WHERE p.post_date < '".current_time('mysql')."' AND p.post_status = 'publish' AND ".$where." AND pm.meta_key = 'views' AND p.post_password = '' ORDER BY views DESC LIMIT ".$limit);
$output_format = $output_format['mostviewsnobot'];
}
if( $most_viewed ) {
$output = '';
foreach($most_viewed as $post) {
$post_title = $post->post_title;
$post_views = number_format(intval($post->views));
$link = '<a href="'.get_permalink().'">'.snippet_chars($post_title, $chars).'</a>';
$output .= '<li>'.sprintf($output_format,$post_views,$link).'</li>'."\n";
}
} else {
$output = '<li>'.__('N/A', 'wp-postviews_plus').'</li>';
}
if( $display ) {
echo $output;
} else {
return $output;
}
}
}
Now my question is: what would I have to do / what code would I have to change / replace so that the output is actually shown?
Hope that makes sense and sorry about the stretched screen ..
Thanks in advanced,
Jason


Sign In
Create Account

Back to top









