WP Conditional Shortcodes

Use WordPress conditional tags as shortcodes. This plugin is a fork of Conditional ShortCodes by John Leavitt.

Plugin available on WordPress.org plugin repository

WordPress Conditional Shortcodes now allows one to specify the pages and categories that content in the shortcode will display on by using shortcode parameters. Add the ID or IDs of specific pages or categories in order to show content on those pages/categories only.

Example: To show content on a page with the ID 7, your shortcode would look like so:

[is_page ids="7"]My content here[/is_page]

To display on a second page, just add the ID of that page as well:

[is_page ids="7, 13"]My content here[/is_page]

For categories:

[is_category ids="5, 8"]My content here[/is_category]

Supported conditional shortcodes:

  • is_single – if showing a single post.
  • is_singular – if showing a single post or page.
  • is_page – if showing a single page. Use the optional parameter “ids” to specify specific pages.
  • is_home – if showing the blog home.
  • is_front_page – if showing the front page of the site.
  • is_sticky – if the current post or page is ‘sticky’.
  • is_category – if showing a category-based archive. Use the optional parameter “ids” to specify specific categories.
  • is_tag – if showing a tag-based archive.
  • is_tax – if showing a tag- or category-based archive.
  • is_author – if showing an author-based archive.
  • is_archive – if showing any archive.
  • is_year – if showing a yearly archive.
  • is_month – if showing a monthly archive.
  • is_day – if showing a daily archive.
  • is_time – if showing an hourly or shorter archive.
  • is_feed – if generating a feed.
  • is_search – if showing search results.
  • comments_open – if comments are open for the current post or page.