Docs

Display conditions

Show or hide an element based on the visitor, date, page, device and many other rules.

On this page

Display conditions decide whether an element is part of the page at all. Show a "Welcome back" line only to logged-in visitors, a banner only during a sale, a block only to people who arrive from a campaign link, or a badge only on posts with a certain category. Conditions are checked on the server when the page is built: a hidden element is not in the page's code, not merely hidden with CSS.

The Conditions section of the Behaviour tab with two rule sets: URL parameter utm_campaign is spring, or Date from 1 December until 24 December
A banner shown to campaign visitors, or to everyone during a date range.

To choose where a whole template (a header, a footer, a popup, a single post layout) appears, use template conditions instead. To hide an element on phones or tablets only, use Visibility.

Add a condition

  1. Select the element

    Select any element: a widget or a whole container.

  2. Open Conditions

    In the inspector, open the Behaviour tab and the Conditions section.

  3. Add a rule

    Click Add a condition. Choose the rule in the first list (for example Visitor or Date), then its operator and value.

  4. Combine rules

    Click And to add a rule that must also be true. Click Or another set to add a second, separate group of rules.

The element shows when any set matches, and a set matches when every rule in it is true. In the example above, the banner shows to visitors who arrive with ?utm_campaign=spring in the address, or to everyone between 1 and 24 December.

Remove a rule with the × next to it. When no rule is left, the element always shows.

Note

The editor canvas always shows every element, whatever its conditions, so you can still edit it. Check the result with Preview, or in a private window for visitor rules. In Layers, elements with conditions are marked with a person icon.

The visitor

RuleOperatorsValue
Visitor—logged in or logged out.
User roleis, is notOne or more roles (Administrator, Editor, Subscriber…). is matches visitors who have one of them; visitors who are not logged in never do.
Browseris, is notChrome, Safari, Firefox, Edge, Opera, Samsung Internet.
Operating systemis, is notWindows, macOS, iOS, Android, Linux.
Languageis, is notThe language being shown. With WPML or Polylang you pick from your languages; otherwise type codes such as en, de (the site language).
The Conditions section of a heading with the rule Visitor is logged in
A greeting shown only to logged-in visitors.

Date and time

All dates and times use the time zone of your site (Settings → General in WordPress).

RuleOperatorsValue
Datefrom, until, isA date, with an optional time. A date alone counts whole days; with a time, it is exact to the minute. is matches that one day.
Time of dayfrom, untilA time such as 09:00.
Day of the weekis, is notOne or more days, Monday to Sunday (a new rule starts with Monday to Friday).

For a limited offer, put Date from and Date until in the same set. For opening hours, combine Time of day from 09:00, Time of day until 17:00 and Day of the week is Mon–Fri in one set.

The page and its content

These rules look at the page being viewed. Inside a loop item or a query loop, the content rules look at each item of the loop instead, so you can, for example, show a badge only on some cards.

RuleOperatorsValue
Pageis, is notA page or post, picked from a list. Compares with the page the visitor is on.
Kind of pageis, is notHome page, Blog, Single post / page, Category, Tag, Other taxonomy, Author, Date archive, Search results, Post type archive, 404.
Post typeis, is notOne or more post types (Posts, Pages, a custom type).
Category / tag / termis, is notChoose the Taxonomy, then type slugs or IDs separated by commas. Matches posts that have one of the terms, and the archive pages of those terms.
Authoris, is notUsernames or user IDs. Matches posts by these authors, and their author archives.
Parent pageis, is not, has a parent, is top levelA parent page picked from a list.
Featured imageis set, is missing—
Comment countgreater than, less than, isA number.
Custom fieldexists, does not exist, is, is not, contains, greater than, less thanType the field name (for example price), then the value. greater than and less than compare numbers. See Custom fields.
Dynamic valueis not empty, is empty, is, is not, contains, greater than, less thanPick a dynamic tag (tags without options, such as Post excerpt or Current user name), then the value to compare with.

The address and the visit

RuleOperatorsValue
URL parameterexists, does not exist, is, is not, containsType the parameter name (for example utm_source), then the value. ?utm_source=newsletter in the address is newsletter.
Came from (referrer)contains, does not contain, is empty (direct visit), is not emptyPart of the address of the previous page, for example google. or instagram.com. is empty matches visitors who typed the address or used a bookmark.
Cookieexists, does not exist, is, containsType the cookie name, then the value.

Examples

  • Members-only content: Visitor is logged in. Add a second element with Visitor is logged out that invites people to sign in.
  • Campaign landing block: URL parameter utm_campaign is spring.
  • Holiday notice: Date from 20 December and Date until 2 January.
  • Badge on some cards: in a loop item, Category / tag / term → Categories is renovation shows the badge only on renovation posts.
  • Hide an empty block: Custom field client_quote exists.

Caching

Because conditions are checked when the page is built, a full-page cache can serve the same version to everyone. Rules about the visitor's login or role need a cache that keeps logged-in visitors separate (most caching plugins do this by default). For rules on dates, URL parameters, cookies, the referrer or the browser, exclude the page from the cache or use a short cache time.