Template:If in category

Revision as of 17:59, 6 September 2024 by Wikipedia>MusikBot II (Changed protection settings for "Template:If in category": High-risk template or module: 32537 transclusions (more info) ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite)))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Template documentation follows
Note: the template above may sometimes be partially or fully invisible.
Visit "Template:If in category/doc" to edit its documentation if it is available. (How does this work?)

This template checks if a page is in a given category. The syntax is:

{{If in category|category name|output if the page is in the category|output if the page is NOT in the category|page=page name to test}}

Usage notes

  • If no |page= parameter is supplied, it defaults to the current page
  • The category name parameter treats Foo and Category:Foo as equivalent
  • If neither output parameter is specified, it outputs yes if true and the empty string if false

Examples

Information Note: This page is in Category:X1.

  • {{If in category|page=Amastra subsoror|Extinct gastropods|Dead as the dodo|Perhaps it's still alive}} → Perhaps it's still alive
  • {{If in category|page=Amastra subsoror|Category:Extinct gastropods|Dead as the dodo|Perhaps it's still alive}} → Perhaps it's still alive
  • {{If in category|page=Amastra subsoror|Extinct gastropods}} →
  • {{If in category|X1}} → yes
  • {{If in category|X1||no}} →
  • {{If in category|X2}} →

TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:If in category in articles based on its TemplateData.

TemplateData for If in category

Checks whether a page is in a category, and returns different output based on the answer.

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Category1

Category being checked to see if the page is in it; "Category:" prefix is optional

Example
Category:X1
Page namerequired
If yes2

Output if the page is in the category. If neither "If yes" nor "If no" are set, defaults to "yes".

Contentsuggested
If no3

Output if the page is not in the category

Contentsuggested
Pagepage

Page being checked. Defaults to the current page.

Default
FULLPAGENAME
Page nameoptional