GWcode Categories Examples

Here are some examples to demonstrate what you can do with GWcode Categories:

Example 4 - Showing the entry count for categories

Version 1.1 of GWcode Categories introduced a new variable called entry_count, which you can use to show the number of entries in a category. Using this variable, it's easy to create a navigation menu with the number of entries next to each category:

The code below will create the menu and show the total number of entries in the categories:

{exp:gwcode_categories channel="example" entry_count="yes"}
	<a href="{path="examplepath/{cat_url_title}"}">{cat_name}</a> ({entry_count})
{/exp:gwcode_categories}

To only show the number of entries with a certain status, you can use the status parameter. If you use the status parameter, the entry_count parameter will effectively be set to "yes", so you don't need to add that one:

{exp:gwcode_categories channel="example" status="open|approved"}
	<a href="{path="examplepath/{cat_url_title}"}">{cat_name}</a> ({entry_count})
{/exp:gwcode_categories}

Version 1.1 of the plugin also introduced the show_empty parameter. It allows you to show only categories with entries (optionally with a certain status):

{exp:gwcode_categories channel="example" status="open" show_empty="no"}
	<a href="{path="examplepath/{cat_url_title}"}">{cat_name}</a> ({entry_count})
{/exp:gwcode_categories}

Here's an example of how you select a category's children categories and then also show their entry count:

{exp:gwcode_categories channel="example" status="open" cat_id="12"}
	<a href="{path="examplepath/{cat_url_title}"}">{cat_name}</a> ({entry_count})
{/exp:gwcode_categories}