Help:Category Ⅲ【後半】Categories…
Listing all categories
Special:Categories provides an alphabetic list of all categories, with the number of members of each; this number does not include the content of the subcategories, but it includes the subcategories themselves, i.e., each counting as one.
The above list contains all categories that have members, regardless of whether they have corresponding category pages. To list all existing category pages (regardless of whether they have members), use Special:AllPages/Category:.
Displaying category trees and page counts
As described at mw:Help:Magic words, {{PAGESINCATEGORY:Example}}
or {{PAGESINCAT:Example}}
returns the number of pages in "Category:Example". Each subcategory counts as one page; pages in subcategories are not counted.
The page Special:CategoryTree enables you to see the tree structure of a category (its subcategories, their subcategories and so on; the display of files and other member pages is optional).
The CategoryTree extension can be used to display such a tree on any page. (This is sometimes done on the category page itself, if the category is split over multiple screens, to make all subcategories available on every screen.) The basic syntax is
<categorytree>Category name</categorytree>
to display just the subcategory tree, and
<categorytree mode=pages>Category name</categorytree>
to display member pages as well. They will be indicated by italics.
Dapete's category-visualizer vCat will render charts of the tree structure.
You may also use Template:Category tree or Template:Category tree all, instead.
Warning:
- The following code
{{PAGESINCATEGORY:{{PAGENAME}}}}
will not work as expected when used in the wikitext or in a transcluded template in a category page whose title contains some ASCII punctuations. - For legacy reasons,
{{PAGENAME}}
may return the page name with these characters being HTML-encoded using numeric character entities : this still works for generating derived wikilinks or displaying page names, or when HTML-encoded this page name is used in a conditional "#switch", but PAGESINCATEGORY does not recognize the category name given in parameter if some characters are HTML-encoded (this is the case notably when the category name contains ASCII apostrophes'
and a few other ASCII punctuations. (The same HTML-encoding is also applied to the values returned by{{FULLPAGENAME}}
,{{SUBPAGENAME}}
, or{{NAMESPACE}}
). - In that case, as the category is not found by its HTML-encoded pagename, PAGESINCATEGORY will unexpectedly return 0 and not its effective number of member pages.
- A simple workaround is to transform these HTML-encoded characters back into standard UTF-8-encoded characters, by using the
{{titleparts:}}
parser function, like this: {{PAGESINCATEGORY:{{titleparts:{{PAGENAME}}}}}}
Retrieving category information
Raw information about the members of a category, their sortkeys and timestamps (time when last added to the category) can be obtained from the API, using a query of the form:
- http://en.wikipedia.org/w/api.php?cmtitle=Category:Category_name&action=query&list=categorymembers&cmlimit=500&cmprop=title|sortkey|timestamp
Listings of up to 500 members are possible. If there are more members then the results will include text near the end like this: <categorymemberscmcontinue="page|NNNN|TITLE" />
.
This can be added to the previous one, without quotation marks, for the next page of members: ...&cmcontinue=page|NNNN|TITLE
.
Category intersection, union, etc.
See also: § Searching for articles in categories
See also Wikipedia:Category intersection.
See also Wikimedia bug T3497 "Hierarchical category system is urgently needed".
How to find articles for a category
The easiest way to find relevant articles for a new category or missing entries in an existing one is by finding the most relevant list and checking its entries. Sometimes categories are about things that are intersections of other categories for which the PetScan tool can be used.
More relevant articles may also be found linked in a category's main article and the articles already featured in the category − especially in their "See also" sections (if existent) and the automatically suggested "RELATED ARTICLES" below them.
Furthermore, a category's superordinate categories often feature articles that should be subcategorized to the category.
Other ways to find relevant articles include searching Wikipedia for the category's topic and searching the Web for the topic in quotes "
(with synonyms also in quotes and appended after an OR
) and appending the word wiki
or Wikipedia
or site:Wikipedia.org
to them.
Lastly the most effective way of finding entries is using the "What links here"-tool on the category's main article.
See also
Notes
- Jump up^ The category itself is permanently created as soon as it has been saved on to any page. Unless you create a category page, it will display as a red link. Unless you add another category to the category page, it will not be placed in the category tree. Category pages are created like any other page. Most commonly, editors click on the redlink in an article and create the category page that way.