popular category plugin
-
Servus,
ive read that the pop cat plugin is resulting some errors when using it with ver 1.5+… so far it’s the only plugin script for that case and i cant built my own … i tried it but it might be easier if there would be a list of the cmd changes of the new wp releases.. i think thats the only reason for errors in that skript
function zm_popular_categories($zmpc_days = 30, $zmpc_title = 0, $zmpc_limit = 10, $zmpc_shownumber = 0, $zmpc_titlename = '<h2>Popular Categories</h2>', $zmpc_pretags = '<div class="headlines">' , $zmpc_posttags = '</div>', $zmpc_prelist = '<span style="float: right;">', $zmpc_postlist = '</span>', $zmpc_countsepstart = '<span>(', $zmpc_countsepend = ' Posts)</span>', $zmpc_return = 0, $zmpc_lastupdated = 0) { global $wpdb, $post; // Draw posts along with relevant associated category data from database $zmpc_posts = $wpdb->get_results(" SELECT p.ID, p.post_title, p.post_date, c.cat_ID, c.cat_name, p2c.post_id, p2c.category_id FROM ($wpdb->posts p LEFT JOIN $wpdb->post2cat p2c on p.ID = p2c.post_id) LEFT JOIN $wpdb->categories c ON p2c.category_id = c.cat_ID WHERE post_status = 'publish' AND p.post_date > DATE_ADD(CURDATE(), INTERVAL -$zmpc_days DAY) ORDER BY p.post_date DESC "); // Initialisations $zmpc_catcounts = array(); $zmpc_caturls = array(); foreach ($zmpc_posts as $zmpc_post) { if (!array_key_exists($zmpc_post->cat_name, $zmpc_catcounts)) { $zmpc_catcounts[$zmpc_post->cat_name] = 1; $zmpc_caturls[get_category_link($zmpc_post->cat_ID)] = 1; } else { $zmpc_catcounts[$zmpc_post->cat_name]++; $zmpc_caturls[get_category_link($zmpc_post->cat_ID)]++; } } arsort($zmpc_catcounts); arsort($zmpc_caturls); $zmpc_cattitles = array_keys($zmpc_catcounts); $zmpc_permalinks = array_keys($zmpc_caturls); $zmpc_travelcount = 0; $html_out .= '<div class="zm_pop_cats">'; if ($zmpc_title) { $html_out .= $zmpc_titlename; } $html_out .= $zmpc_prelist; foreach ($zmpc_catcounts as $zmpc_catcount) { $html_out .= $zmpc_pretags; $html_out .= '<a href="'.$zmpc_permalinks[$zmpc_travelcount].'">'.$zmpc_cattitles[$zmpc_travelcount].'</a>'; if ($zmpc_shownumber) { $html_out .= $zmpc_countsepstart; $html_out .= $zmpc_catcount; $html_out .= $zmpc_countsepend; } $html_out .= $zmpc_posttags; $zmpc_travelcount++; if ($zmpc_travelcount >= $zmpc_limit) break; } $html_out .= $zmpc_postlist; $html_out .= '</div>'; if($zmpc_return) return $html_out; else echo $html_out; } ?>
so where are the failures ?
its a short but usefull skript , even because ive found nothing similar to that!
- The topic ‘popular category plugin’ is closed to new replies.