Include or Exclude Categories

To sort categories alphabetically and include only the categories with IDs of 16, 3, 9 and 5, you could write the following code:

wp_list_categories('orderby=name&include=3,5,9,16'); ?>

The following example displays category links sorted by name, shows the number of posts for each category, and excludes the category with the ID of 10 from the list.

wp_list_categories('orderby=name&show_count=1&exclude=10'); ?>

Display or Hide the List Heading

The title_li parameter sets or hides a title or heading for the category list generated by wp_list_categories. It defaults to '(__('Categories')', i.e. it displays the word “Categories” as the list’s heading. If the parameter is set to a null or empty value, no heading is displayed. The following example code excludes categories with IDs 4 and 7 and hides the list heading:

wp_list_categories('exclude=4,7&title_li='); ?>

In the following example, only Cateogories with IDs 9, 5, and 23 are included in the list and the heading text has been changed to the word “Poetry”, with a heading style of <h2>:

wp_list_categories('include=5,9,23&title_li=<h2>' . __('Poetry') . '</h2>' ); ?>


2 Responses to “Include or Exclude Categories”

  1. Roulette System Says:

    Hey, ok, I get it, I guess – but does this really work?

  2. Tony Pacise Says:

    There is obviously a lot to learn. There are some good points here.

    surface encounters macomb mi

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: