Skip to content

Conditions

An image’s Conditions view decides where WordPress uses it. Without any condition group an image is never used automatically; it can still be rendered with the PHP functions or the shortcode.

Groups and rows

Add new condition adds a group. A group starts with its output, and And adds rows that narrow it down.

  • All rows in a group must match.
  • Groups are independent: the image is used for every group that matches.
  • Each group has one output. To use an image for two outputs, for example Open Graph and Featured image, add a group for each.

Each row compares a parameter with a value using is equal to or is not equal to.

Outputs

Open Graph, Twitter Card, Open Graph + Twitter Card

On a matching front-end page Pixel writes the rendered image into the page’s og:image tag, the twitter:image tag, or both. It replaces the tag an SEO plugin or theme printed, and an og:image:secure_url tag when there is one, keeps a single copy of each, and adds og:image or twitter:image when the page has none. The image is rendered for the page’s current post.

Pixel replaces the featured image of every matching post wherever the theme shows it, with the rendered image at the canvas’s size and an empty alt. Each post is checked as it appears, so on an archive one design can give every post its own image.

A post without a featured image of its own gets one too. WordPress needs a media library attachment to print featured image markup, so Pixel borrows the newest one as a stand-in, which requires at least one item in the media library.

Block editor sidebar

Pixel adds a panel to the block editor’s sidebar that shows the image rendered for the post being edited, with a Download button. The group’s Panel name is the panel’s title, SleekPixel when left empty.

The panel evaluates only the Post type, Post and Post status rows of its group and treats every other row as met. It appears only for users who can manage options, as the panel renders through Pixel’s REST operations.

Parameters

Values

  • Post type, Post, Post status and Page template: the current post’s type, ID, status and page template.
  • Taxonomy: matches the archive of a taxonomy, such as a category or tag archive. It does not match single posts; use Term for those.
  • Term: chosen by searching the site’s public taxonomies. On a single post, and for each post when featured images are replaced, matches when the post has the term in any taxonomy. On a term archive it matches when the archive is that term.

WordPress conditions

Each corresponds to a WordPress conditional tag, compared with the true or false chosen in the row: Single is equal to true matches single posts, and is equal to false or is not equal to true every other page. A row saved without a value counts as true.

Parameter Tag
Is home is_home()
Is front page is_front_page()
Is page is_page()
Is single is_single()
Is singular is_singular()
Is search page is_search()
Is archive is_archive()
Is post type archive is_post_type_archive()
Is category archive is_category()
Is tag archive is_tag()
Is taxonomy archive is_tax()
Is author archive is_author()
Is date archive is_date()
Is year archive is_year()
Is month archive is_month()
Is day archive is_day()
Is time archive is_time()
Is attachment is_attachment()
Is a 404 page is_404()
Has featured image has_post_thumbnail() for the current post

Custom

Conditions a site registers with the sleekPixel/conditions filter appear under their label. Each has an id, a label and a value computed for the current request.

  • When the id starts with is or has and the value is a boolean, the row works like a WordPress condition and compares the value with the true or false chosen in the row.
  • Otherwise the row compares the value with the text you enter.

Use an id in lowercase letters, digits, _ and -. The editor stores the row as custom_ followed by the ID WordPress’s sanitize_key() makes of it, which lowercases it, while the front end compares with the ID as registered, so an ID with capital letters never matches. See PHP hooks for an example.

Stay in the Loop!  

Be the first to hear about new updates, special offers, and helpful tips, delivered straight to your inbox.

We respect your inbox (and your privacy). Read our privacy policy.