A Blog about Linux, Open Source and Code! 
Symsys Inform Blog Home

Symsys Ltd Text logo in the banner area


Author:  Symsys
October 18, 2008



 

 

Ever since the recent update of WordPress to the new WordPress 2.6.2 all the How To’s out there on the web are getting slightly out of date due to things not being the same in the code of the updated WordPress. This naturally causes some confusion with those out there that are not used to editing PHP and are cautious about editing source code.

This is to correct the layout glitch of the what should be a simple function of adding post counts next to category items.

The easy part – adding the function in the WordPress Site Admin.

Go to Design >> Widgets >> Edit the ‘Categories’ widget (of course make sure it is added as a current widget)
Tick the box that says ‘Show Post Counts’ – hit ‘Change’, then ‘Save Changes’ at the bottom.

Problem occurs that the post count is displayed as a link UNDER the category text making the list very messy and very long. The purpose of this post is to simply give the correct line numbers and exact code that exists in wordpress 2.6.2 which is different from older versions and make it easier for people.

 

Download ‘ classes.php’ from the ‘wp-includes’ directory and edit is as follows.

lines 674 & 645 says
 

	if ( isset($show_count) && $show_count )
			$link .= ' (' . intval($category->count) . ')';

Comment this out by putting in two forward slashes // or simply delete it.

On line 644
REPLACE :

$link .= $cat_name . '';

WITH:

$link .= $cat_name;
if ( isset($show_count) && $show_count ) {
$link .= ' (' . intval($category->count) . ')'. '';
}

Save and upload it again to overwrite the original classes.php in the wp-includes directory and thats it – Done.


Filed under: Code,Wordpress ... Comments (3)

Tags: , , , , ,
  

 





Enter your email address:

Delivered by FeedBurner