- Posts Categories Screen
- Topics
- Categories Screen
- Add New Category
- Table of Categories
- Screen Options
- Search
- Using Selection, Actions, and Apply
- Selection
- Actions
- Apply
- Quick Edit
- Edit Category
- Developer Resources
- Contents
- Parameters
- Return
- More Information
- Usage
- Source
- Hooks
- Related
- Used By
- Changelog
- User Contributed Notes
- Feedback
Posts Categories Screen
Topics
Each post in WordPress is filed under one or more Categories. This aids in navigation and allows posts to be grouped with others of similar content.
Each Category may be assigned to a Category Parent, allowing you to set up a hierarchy within the Category structure. In creating Categories, recognize that each Category Name must be unique. Thus, even if two Categories have two different Parents, they must still have different names.
Links to your Categories are, by default, shown in two different places on your blog’s home page if you are using the WordPress Twenty Seventeen theme. First, WordPress lists these Category as links in your sidebar. Second, WordPress shows all the Categories to which a given post belongs under that post. When someone viewing your blog clicks on one of these Category links, an archive page with all the posts belonging to that Category will be displayed.
This Screen allows you to create new Categories, edit or delete existing ones, and organize your Categories hierarchically.
Categories Screen
This Screen is divided into the Add New Category and Category Table sections.
Add New Category
This part of the Screen, which is conveniently linked to from the top of the Table of Categories, allows you to create a new Category. There are four pieces of information associated with each new Category: the name, slug, category parent, and description.
Name: To reiterate, the Category Name must be unique.
Slug: The Category slug must be unique. The Category Slug is used in the URL. For example, setting a Category Name of “Recipes” and a Category Slug of “food” would show all “Recipes” posts with a URL like example.com/blog/food/.
Parent: Use this drop-down if you want to make this Category a sub-Category; you will select the sub-Category’s Parent here. For example, you may have a Category called “Photos” but want to add further clarification about the subject of a particular “Photos” post. You could add “Oregon Coast” and “Ice Storm” as sub-Categories to the “Photos” Category; “Photos” would be the Parent of these two new sub-Categories.
Sub-Categories show up on your blog’s page just like Categories, except they will typically be nested under their Parent Categories. When someone visits your site and clicks the “Photos” Category link, all posts in “Photos” and all its sub-Categories will be displayed. Clicking the “Oregon Coast” Category link only displays those post in that sub-Category. If you assign a post to a sub-Category (e.g. “Oregon Coast”), you can choose to assign that post to the sub-Category’s parent (“Photos”) or not. Either way, all “Oregon Coast” posts will show up in the “Photos” Category page. The only difference is that the list of Categories of which a particular post is actually a member. In the WordPress WordPress Twenty Seventeen theme, this list is shown below the text of each post. Please note that when creating templates, you cannot match a child category based on the parent (ie: if category “bar” has parent “foo”, a template file named “category-foo.php” will not match any “bar” category posts.)
Description: Category Descriptions are optional. Some themes take advantage of Category Descriptions, others do not, so having Descriptions may or may not modify the way Categories are displayed for your site. Even if they are not used by your site’s theme, you may still find them useful from an administration point of view.
Add New Category: The most important part of the Add New Category box. Once you’ve entered in all the information about your new Category, use this button to save it.
Table of Categories
This table lists all of your categories by row. Categories are displayed hierarchically and alphabetically; subcategories are displayed beneath their parents and are prefaced by long dashes. These dashed are not part of a Category’s name; they are there only to show hierarchy.
The table of categories contains the following columns:
- [ ] – A checkbox that when clicked (checked), ‘selects’ that particular Category to be deleted when the Delete Action is Applied.
- Name – The name of the Category. (Each name must be unique)
- Description – Categories may have an optional description. By default, the description is shown to viewers when they hover over the category’s link.
- Slug – The slug of a Category. (Usually in lower case letters)
- Posts – The number of posts which are members of the Category. Click on the number in the Posts column to be directed to the All Posts Screen to manage the Posts in that Category.
Screen Options
The Screen Options allow you to choose which columns are displayed, or not displayed, in the underlying Table. Clicking on the Screen Options tab shows a list of the columns with a check-box next to each column. Check the box for each column you want displayed in the Table, or uncheck the box to not display that column. In addition, the number of Categories to display in the Table of Categories can be set. Click the Screen Options tab again to close the Screen Options.
Search
Above the Table, to the right, is a search box where you can enter a word, or series of words, and click the “Search Categories” button to search and display all the Categories meeting your search words.
Using Selection, Actions, and Apply
Selection
This section allows Actions to be performed on one or more Categories displayed in the Table. For Actions to be performed on multiple Categories at once, those Categories must be first selected via one of these methods:
- Select one Category at a time – To select a Category, the checkbox to the left of the Category entry must be checked (clicked). It is possible to keep selecting more Categories by checking their respective checkbox.
- Select all Categories in given Table – All Categories in a given table can be selected by checking the checkbox in the Table’s title, or footer bar. Of course, unchecking the header or footer title bar checkbox will cause all entries in that Table to be unchecked (NOT selected).
- Reverse Selection – A Reverse Selection means checked items become unchecked, and unchecked items become checked. A Reverse Selection is accomplished by holding the Shift key on the keyboard and clicking the header or footer title bar checkbox.
Actions
Actions describe the process to be performed on particular Categories. There are two styles of Actions that will be referred to as Bulk Actions and Immediate Actions. The follow describes these Actions:
- Bulk Actions – These Actions can be performed on one, or more Categories, at one time, if those Categories have been previously selected. Bulk Actions are available, when appropriate, as choices in the Actions pull-down box, above each Table. The only Bulk Action allowed is Delete.
- Immediate Actions – Immediate Actions are performed immediately, on an individual Category. Hovering the mouse cursor over the Category row reveals the Edit, Quick Edit, Delete and View options under the Name column in that Category row. Clicking on a Category Name will also initiate the Edit Action.
The available Actions are described below:
- Edit – This Immediate Action displays the Edit Category Screen to edit the Category fields. This Action can be initiated by click on the Category Name or clicking on the Edit option just below the Category Name.
- Quick Edit – This Immediate Action initiates the Quick Edit of that Category.
- Delete – This Action deletes the Category. Delete is available as a Bulk Action and an Immediate Action. Note: Deleting a category does not delete the posts in that Category, but the posts that were assigned to the deleted Category are assigned to the Default Category, as defined in the Settings Writing Screen. Note that the Default Category cannot be deleted.
- View – This Action, if supported by the active theme’s template, will display the Posts belonging to the Category. View is available only as an Immediate Action.
Apply
After one or more Categories are selected, and after a Bulk Action is specified, the Apply button performs the given Action on the selected Categories.
- Apply – Click the Apply button to execute the Bulk Action, specified in the Actions pull-down, on the selected Categories. Remember, prior to executing Actions, one or more Categories must be selected, as described before.
Quick Edit
The following fields can be change via the Quick Edit Action:
Category name: To reiterate, the Category name must be unique. Category slug Again, the Category slug must be unique.
Cancel: Click this button to cancel any changes and return to the Table of Categories
Update Category: Once you’ve edited all the information about the Category, use this button to save the changes.
Edit Category
This Screen is displayed by clicking on a Categories’ Name in the Table of Categories or clicking on the Edit option just below the Category Name. It is possible to edit four pieces of information associated with each Category: the name, the slug, the parent, and the description.
Category name and Category Slug: Category name and Category Slug must be unique.
Category Parent: Use this drop-down if you want to make this Category a sub-Category; you will select the sub-Category’s Parent here. For example, you may have a Category called “Photos” but want to add further clarification about the subject of a particular “Photos” post. You could add “Oregon Coast” and “Ice Storm” as sub-Categories to the “Photos” Category; “Photos” would be the parent of these two new sub-Categories.
Description: Category descriptions are optional. Some themes take advantage of Category descriptions, others do not, so having Descriptions may or may not modify the way Categories are displayed for your site.
Update: Once you’ve changed the Category information, use this button to save the changes.
Developer Resources
Displays or retrieves the HTML list of categories.
Contents
Parameters
Return
void|string|false Void if ‘echo’ argument is true, HTML list of categories if ‘echo’ is false.
False if the taxonomy does not exist.
More Information
Usage
- No link to all categories
- Sorts the list of Categories by the Category name in ascending order
- Displayed in an unordered list style
- Does not show the post count
- Displays only Categories with posts
- Sets the title attribute to the Category Description
- Is not restricted to the child_of any Category
- No feed or feed image used
- Does not exclude any Category and includes all Categories
- Displays the active Category with the CSS Class-Suffix ‘ current-cat’
- Shows the Categories in hierarchical indented fashion
- Display Category as the heading over the list
- No SQL LIMIT is imposed (‘number’ => 0 is not shown above)
- Displays (echos) the categories
- No limit to depth
- All categories.
- The list is rendered using a new walker object of the the Walker_Category class
Source
Hooks
Filters the HTML output of a taxonomy list.
Related
Uses | Description | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
walk_category_tree() wp-includes/category-template.php |
Used By | Description | |||||||
---|---|---|---|---|---|---|---|---|
wp_list_cats() wp-includes/deprecated.php | ||||||||
WP_Widget_Categories::widget() wp-includes/widgets/class-wp-widget-categories.php |
Version | Description |
---|---|
6.1.0 | Default value of the ‘use_desc_for_title’ argument was changed from 1 to 0. |
4.4.0 | The current_category argument was modified to optionally accept an array of values. |
2.1.0 | Introduced. |
User Contributed Notes
Display Categories Assigned to a Post
Display the categories (or terms from other taxonomies) assigned to a post ordered by parent-child category relationship. Similar to the function get_the_category_list() which orders the categories by name. This example must be used inside the loop.
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:
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.
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:
In the following example, only Categories 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 :
Note that you can use all the arguments implemented for get_terms() function and WP_Term_Query::__construct. So, for example, the arguments meta_key or meta_value can be added and will do their job as well.
Remove Parentheses from Category Counts
When show_count=1, each category count is surrounded by parentheses. In order to remove the parentheses without modifying core WordPress files, use the following code.
Display Terms in a custom taxonomy
With Version 3.0 the taxonomy parameter was added to enable wp_list_categories() function to list Custom Taxonomies. This example list the terms in the taxonomy genre:
All categories divided by comma.
Only Show Children of a Category
The following example code generates category links, sorted by ID, only for the children of the category with ID 8; it shows the number of posts per category and hides category descriptions from the title attribute of the generated links. Note: If there are no posts in a parent Category, the parent Category will not display.
Display Categories with RSS Feed Links
The following example generates Category links sorted by name, shows the number of posts per Category, and displays links to the RSS feed for each Category.
To replace the rss link with a feed icon, you could write:
Markup and Styling of Category Lists
By default, wp_list_categories() generates nested unordered lists (ul) within a single list item (li) titled “Categories”.
You can remove the outermost item and list by setting the title_li parameter to an empty string. You’ll need to wrap the output in an ordered list (ol) or unordered list yourself (see the examples above). If you don’t want list output at all, set the style parameter to none.
You can style the output with these CSS selectors :
‘include’ is missing from the parameter list.
Feedback
This code is a variation of one that already appears here that the last two arrays show the child categories of 17 and then exclude the main category showing only the children.
‘hierarchical’ is missing from the parameter list. — By nicholas.eymann — 2 years ago
You must log in before being able to contribute a note or feedback.
Adblockdetector