• Home
  • Random
  • Nearby
  • Log in
  • Settings
Donate Now If Wikipedia is useful to you, please give today.
  • About Wikipedia
  • Disclaimers
Wikipedia

Template:If in category/sandbox

  • Template
  • Talk
  • Language
  • Watch
  • Edit
< Template:If in category
This is the template sandbox page for Template:If in category (diff).
See also the companion subpage for test cases.
Template documentation[view] [edit] [history] [purge]
WarningThis template is used on approximately 173,000 pages.
To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
Due to a server limit of 500 "expensive parser function" calls (e.g. #ifexist:, PAGESIZE:, and PAGESINCATEGORY:), this template will only work properly if the page using it has not already exceeded the limit. When the limit is exceeded, the page using this template or module is categorised in Category:Pages with too many expensive parser function calls. (further information)
This template uses Lua:
  • Module:If in category (sandbox)

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

edit
  • 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

edit

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}} → Dead as the dodo
  • {{If in category|page=Amastra subsoror|Category:Extinct gastropods|Dead as the dodo|Perhaps it's still alive}} → Dead as the dodo
  • {{If in category|page=Amastra subsoror|Extinct gastropods}} → yes
  • {{If in category|X1}} → yes
  • {{If in category|X2}} →

TemplateData

edit
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
The above documentation is transcluded from Template:If in category/doc. (edit | history)
Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Template:If_in_category/sandbox&oldid=1278979777"
Last edited on 5 March 2025, at 20:18

Languages

      This page is not available in other languages.

      Wikipedia
      • Wikimedia Foundation
      • Powered by MediaWiki
      • This page was last edited on 5 March 2025, at 20:18 (UTC).
      • Content is available under CC BY-SA 4.0 unless otherwise noted.
      • Privacy policy
      • About Wikipedia
      • Disclaimers
      • Contact Wikipedia
      • Code of Conduct
      • Developers
      • Statistics
      • Cookie statement
      • Terms of Use
      • Desktop