Displaying Empty Categories in WordPress Category Widget

The WordPress Categories Widget by default doesn’t display categories which contains no post in them. The widget also doesn’t provide a way to change it from the widget administration screen. One way to change the widget to display the empty categories is by modifying the parameter of the widget in source code.

The default WordPress Categories widget code can be located in the wp-includes/default-widgets.php file and lookup for the WP_Widget_Categories class in that file.

Search for the following line on the default-widgets.php.

$cat_args = array(
    'orderby' => 'name',
    'show_count' => $c,
    'hierarchical' => $h);

This line set the default arguments / parameters for the widget. There is a parameter named hide_empty that can be use to show or hide the empty categories. The default value of this parameter in the Categories widget is 1 which mean true or hide the empty categories. To make it display the empty categories change the above line of code into something like:

$cat_args = array(
    'orderby' => 'name',
    'show_count' => $c,
    'hierarchical' => $h,
    'hide_empty' => 0);

Save the modified file and refresh your blog and you’ll see the empty categories displayed on your blog side bar.

Get Your Free Digital Issue of Java Magazine

Java Magazine is an essential source of knowledge about Java technology, the Java programming language, and Java-based applications for people who rely on them in their professional careers – or aspire to. With contributors ranging from across the ecosystem, Java Magazine is truly designed by, and for, the community.

You can subscribe for a free digital issue from the Java Magazine Official website on the following link http://www.oracle.com/technetwork/java/javamagazine/index.html.

Java SE Installation Tutorial

Summary: This tutorial is about Java Development Kit (JDK) Standard Edition installation guide. After reading and executing this tutorial you will be able to install the JDK and setting the basic configuration for running the Java compiler from the command line. You will also learn how to create, compile and run a simple Hello World program written in Java. Continue reading