Shortcode
Bannerize provides several shortcodes for displaying banners in posts, pages, widget areas, or anywhere WordPress processes shortcodes. The primary shortcode is [wp_bannerize_pro], with specialized variants for device targeting and geolocation.
Primary Shortcode
[wp_bannerize_pro]Without any attributes, this displays all published and active banners.
Attributes
| Attribute | Type | Description | Default |
|---|---|---|---|
id | integer | Display a specific banner by its post ID | — |
numbers | integer | Maximum number of banners to show | All |
campaigns | string | Filter by campaign slug(s), comma-separated | All |
orderby | string | Sort order: menu_order, impressions, clicks, ctr, random | menu_order |
order | string | Sort direction: ASC or DESC | DESC |
layout | string | Display layout: vertical or horizontal | vertical |
rank_seed | integer | Custom seed for randomization consistency | — |
mobile | boolean | Show only on mobile devices: true or false | — |
desktop | boolean | Show only on desktop devices: true or false | — |
post_categories | string | Show only on posts in these categories (comma-separated slugs) | — |
Examples
Display a Specific Banner
[wp_bannerize_pro id="42"]Display Banners from a Campaign
[wp_bannerize_pro campaigns="sidebar-ads"]Display Multiple Campaigns
[wp_bannerize_pro campaigns="header-ads,footer-ads"]Limit Number of Banners
[wp_bannerize_pro campaigns="holiday-sale" numbers="3"]Random Order
[wp_bannerize_pro campaigns="sidebar-ads" numbers="1" orderby="random"]This displays one random banner from the “sidebar-ads” campaign on each page load.
Horizontal Layout
[wp_bannerize_pro campaigns="header-ads" layout="horizontal"]Displays banners side by side instead of stacked vertically.
Sort by Performance
[wp_bannerize_pro orderby="clicks" order="DESC" numbers="5"]Shows the top 5 most-clicked banners.
Sort by CTR
[wp_bannerize_pro orderby="ctr" order="DESC" numbers="3"]Shows the 3 banners with the highest click-through rate.
Consistent Randomization with rank_seed
[wp_bannerize_pro orderby="random" rank_seed="12345"]The rank_seed attribute provides a consistent random order for the same seed value. This is useful when you want the same “random” arrangement to persist across page loads or for A/B testing.
Filter by Post Category
[wp_bannerize_pro post_categories="technology,gadgets"]This banner will only display when the current post belongs to the “technology” or “gadgets” categories. On all other posts, the shortcode outputs nothing.
Device-Specific Shortcodes
Bannerize provides dedicated shortcodes for targeting specific device types:
Mobile Only
[wp_bannerize_pro_mobile campaigns="mobile-ads" numbers="1"]This shortcode only renders on mobile devices. It accepts all the same attributes as [wp_bannerize_pro].
Device detection uses the mobile and desktop attributes internally. The dedicated shortcodes are convenience wrappers — you can achieve the same result with [wp_bannerize_pro mobile="true"] or [wp_bannerize_pro desktop="true"].
Geolocation Shortcode
Target banners by visitor country using the geo shortcode:
[wp_bannerize_pro_geo countries="US,UK,CA" campaigns="english-ads"]| Attribute | Description |
|---|---|
countries | Comma-separated list of ISO 3166-1 alpha-2 country codes |
The geo shortcode accepts all the standard [wp_bannerize_pro] attributes in addition to countries.
Geolocation requires an IPStack API key configured in Bannerize > Settings > Geolocalization. Without a valid API key, the geo shortcode will not filter by country and will display banners to all visitors.
Geo Shortcode Examples
Display different banners for different regions:
[wp_bannerize_pro_geo countries="US" campaigns="us-promotions"]
[wp_bannerize_pro_geo countries="DE,FR,IT,ES" campaigns="eu-promotions"]
[wp_bannerize_pro_geo countries="JP" campaigns="japan-promotions"]Combining Attributes
You can combine multiple attributes for precise control:
[wp_bannerize_pro campaigns="sidebar-ads" numbers="2" orderby="random" layout="vertical" desktop="true" post_categories="news"]This displays 2 random vertical banners from the “sidebar-ads” campaign, only on desktop devices, and only on posts in the “news” category.
Using in Widget Areas
Shortcodes work in WordPress text widgets. Add a Text or Custom HTML widget to any sidebar or widget area and paste the shortcode:
[wp_bannerize_pro campaigns="sidebar-ads" numbers="3"]For a more user-friendly widget experience with a graphical interface, consider using the dedicated Bannerize Widget instead.
Shortcode in PHP Templates
To use the shortcode in a PHP theme template:
echo do_shortcode('[wp_bannerize_pro campaigns="footer-ads" numbers="2"]');However, for theme templates, the dedicated PHP functions are recommended as they offer better performance and type safety.