Yeap, 136 is the post ID. And I even put it directly under the loop.
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<?php wpp_get_views(136); ?>
I did a little debugging with it’s function.
function wpp_get_views($id = NULL) {
// have we got an id?
if ( empty($id) || is_null($id) || !is_numeric($id) ) {
echo "alert!";
return false;
} else {
global $wpdb;
$table_name = $wpdb->prefix . "popularpostsdata";
$result = $wpdb->get_results("SELECT pageviews AS 'views' FROM $table_name WHERE postid = '$id'", ARRAY_A);
if ( !is_array($result) || empty($result) ) {
return "0";
} else {
return $result[0]['views'];
}
}
}
It seems like it’s not getting and ID.