The [show]
shortcode can be used to conditionally show contents only on certain pages.
It can be useful when adding content to global locations, such as widget areas, "before header content", "after page content", "before footer content", etc.
In template files the shortcode can be called using <?php echo do_shortcode('[show on="blog"] ... [/show]'); ?>
.
Show shortcode arguments
on | Match keyword [home|front|blog|singular|sticky|archive|search|rtl|404|wc|shop|cart|checkout|account]. | ||
post_type | Match post type [post|page|product|...]. | ||
category | Match a category name, slug or ID. | ||
tag | Match current post tags. | ||
tax | Match current taxonomy. | ||
author | Match an author name, slug or ID. | ||
single | Match a single post of any post type by name, slug or ID. | ||
page | Match a page by name, slug or ID. | ||
path | Match a path. | ||
when | Match state [logged-in|logged-out]. | ||
locale | Show content only if current locale matches the specified locale (case-insensitive) [en_US|en_GB|de_DE...]. | ||
wc_endpoint | Match a WooCommerce endpoint slug [order-pay|order-received|view-order|edit-account|edit-address|lost-password|customer-logout|add-payment-method]. | ||
Classes |
| ||
operator | Operator between multiple arguments [OR|AND|NOT] (default: OR). |
[show on="front"]
[button]Button[/button]
[/show]
[show on="front" operator="NOT"]
[button]Button[/button]
[/show]
Message shown only on Cart or Checkout page
[show on="cart, checkout"]
[message info][icon info]Use Coupon SUMMER2018 for 10% off on all orders.[/message]
[/show]
[show post_type="post"]
[button]Button[/button]
[/show]
[show category="Shortcodes"]
[button]Button[/button]
[/show]
[show tag="test"]
[button]Button[/button]
[/show]
Segment shown only on posts that are created by "websevendev"
[show author="websevendev"]
[segment]
[header]
[subheader]Author[/subheader]
websevendev
[/header]
[/segment]
[/show]
[show single="show"]
[button]Button[/button]
[/show]
[show page="About"]
[button]Button[/button]
[/show]
[show path="/contact"]
[button]Button[/button]
[/show]
[show when="logged-in"]
[button]Log out[/button]
[/show]
[show when="logged-out"]
[button]Log in[/button]
[/show]
[show locale="en_US"]
[button]Hello[/button]
[/show]
[show locale="en_AU"]
[button]G'day[/button]
[/show]
[show wc_endpoint="order-received, view-order"]
[button]Button[/button]
[/show]
[show on="wc"]
[button]Button[/button]
[/show]