Skip to main content

Shortcodes

Three shortcodes. One renders a price, one renders a buy button, and one renders a currency toggle.

All three are blocks as well. In the block editor they are under Widgets in the inserter, with dropdowns instead of typed attributes, and a shortcode converts to a block, or a block to a shortcode, in a click. See Blocks. The shortcodes stay: they are what a page builder, a classic editor, a widget area or a template file wants, and everything below is true of both.

Every attribute on every one of them is optional. Leave an attribute out and the plugin uses your product's headline row, so the shortest form works:

[pflp_price] -> $25
[pflp_button] -> a Buy now button linking to that price's checkout
[pflp_currency] -> a currency toggle, where there is more than one currency

The product's own screen under Freemius Pricing, Products shows exactly what those three render for your product, and a ready-made shortcode for every plan, licence tier and billing cycle you sell. Click one to copy it.

What the defaults resolve to

AttributeLeft out, it means
productyour first configured product
planthe plan Freemius marks as featured, otherwise the first plan that has a price
licensesthat plan's lowest numbered licence tier, and unlimited only if it has no numbered tier
cycleannual, falling through to monthly and then lifetime if that row has no annual price

The cycle actually rendered is written into the page as a data-pflp-cycle attribute, so you can always see which one a short form chose.

The fall-through applies only to an attribute you left out. If you write cycle="annual" and that row has no annual price, nothing renders, rather than a monthly figure appearing where you asked for a yearly one.

The free plan

A plan with no price renders nothing from either shortcode, and the product's own screen leaves it out of the Shortcodes table: it has no figure to show and no checkout to link to. For the free tier of a pricing table, use an ordinary link or button, the core Buttons block or your theme's, pointing at the plugin's download page (its WordPress.org listing, usually). That link is a fixed fact rather than a live price, so there is nothing for this plugin to keep current.

[pflp_price]

Renders one price: a plan, at a licence tier, on a billing cycle.

[pflp_price plan="b2" licenses="3" cycle="annual"]
AttributeDefaultWhat it does
planthe featured planThe plan, by its Freemius plan name (b2, personal, pro). Not case-sensitive. A numeric plan id works too, and so does the plan title
licensesthe lowest tierThe licence tier, as a number (1, 3, 10). Use unlimited for a plan with no licence limit
cycleannualmonthly, annual or lifetime
productyour first productOnly needed when the site sells more than one product. Use the product id, or the product's Freemius slug or name
currencynot setFixes this one price to a currency, for example currency="gbp". The currency toggle then leaves it alone
stylesymbolsymbol renders $25. code renders USD 25, for prose where a bare symbol reads oddly
classnot setExtra CSS classes, separated by spaces. Added to the pflp-price class the span always carries, never replacing it
alignnot setleft, center or right. Puts the price in a block of its own and aligns it across the line. Left out, the price stays inline, which is what lets it sit inside a sentence

Examples:

[pflp_price] -> $25
[pflp_price plan="b2" licenses="3" cycle="lifetime"] -> $99
[pflp_price plan="b2" licenses="10" cycle="annual" style="code"] -> USD 75
[pflp_price plan="pro" licenses="unlimited" cycle="monthly"] -> $7.50
[pflp_price product="12345" plan="pro" licenses="1" cycle="annual"] -> $59

Whole prices carry no decimals, anything else carries two, and thousands are grouped in your site's language.

If the row does not exist, nothing renders. A plan name that does not match, a licence tier the plan does not sell, or a cycle with no price, all produce an empty space rather than a wrong number or a 0. The reason is recorded in the plugin's log, on the Logs tab of the Settings screen. Copying the shortcode out of the reference table on the product's own screen avoids this entirely.

[pflp_button]

Renders a buy button: an ordinary link to your Freemius hosted checkout, for the same plan, licence tier and billing cycle a price would render.

[pflp_button]
[pflp_button plan="b2" licenses="10" cycle="annual" label="Buy the 10-site licence"]
AttributeDefaultWhat it does
plan, licenses, cycle, productas aboveExactly the same attributes, defaults and spellings as [pflp_price]
currencynot setFixes this button's checkout to one currency. Without it, the button follows whatever currency the visitor is reading
labelyour site-wide labelThe words on the button. The site-wide default is on the Settings screen and starts as "Buy now"
classyour site-wide classesExtra CSS classes, separated by spaces. Added to the ones the button already carries, never replacing them. All three shortcodes take class; the button is the one that also merges the site-wide classes from the Settings screen
idnot setAn HTML id, for linking to the button or styling that one on its own
widthnot set25, 50, 75 or 100: percent of the block around the button, the same choices as the core Buttons block. On a pricing card, 100 spans the card. Anything else is ignored
alignnot setleft, center or right. Puts the button in a block of its own and aligns it across the line

The button is rendered as:

<a class="wp-element-button pflp-button" href="https://checkout.freemius.com/product/12345/plan/9002/licenses/3/?billing_cycle=annual">Buy now</a>

wp-element-button is the class WordPress itself gives a button, so in most block themes the button already looks like every other button on your site. The plugin's own styling is a plain fallback with no specificity at all, so anything your theme says wins. Add class="..." for a theme that needs its own class as well.

If the row does not exist, no button is rendered at all. A price can leave a gap in a sentence; a button cannot, because a link to a checkout that sells nothing is worse than no link. The reason is recorded in the log, exactly as it is for a price.

[pflp_currency]

Renders a currency toggle, listing only the currencies your product is actually sold in.

[pflp_currency]
AttributeDefaultWhat it does
productyour first productOnly needed when the site sells more than one product
classnot setExtra CSS classes, separated by spaces. Added to the pflp-currency class the toggle always carries, never replacing it
alignnot setleft, center or right. Puts the toggle in a block of its own and aligns it across the line

It renders nothing when there is only one currency. If your product is priced in USD alone, there is no choice to offer, so no control appears. Add EUR and GBP prices in the Freemius dashboard and the toggle appears on its own, with no edit to the page.

A visitor's choice is remembered in their own browser, so the next page they open is already in their currency. You can turn that off in the settings.

One toggle per page is usually right. Every price on the page follows it, and so does every button.

Aligning a price, a button or a toggle

All three render an inline element, which means the text around them decides where they sit. align="center" wraps one in a block of its own and centres it:

[pflp_price align="center"]
[pflp_button align="center"]
[pflp_currency align="right"]

left, center and right are the three values, and anything else is ignored. The price, button or toggle keeps whatever classes and id you gave it; the alignment is on the block around it, so your own styling is untouched. As a block, the same setting is the alignment buttons in the block toolbar.

Leave align out of [pflp_price] when the price is part of a sentence. An alignment puts it on a line of its own, which is right for a figure at the top of a pricing card and wrong in the middle of a paragraph.

Buy buttons you built yourself

[pflp_button] is not the only way to sell. A button built by your theme or page builder works just as well, as long as its link points at checkout.freemius.com: the plugin adds the visitor's currency to any such link on the page, so the checkout opens in the currency they were reading.

If Checkout is set to open in an overlay, a click on such a link opens the Freemius checkout over your page instead of leaving it, carrying the same product, plan, licences, billing cycle and currency. Anything the overlay cannot be given exactly falls back to the hosted checkout page, so a button always works.

A button with a fixed currency is the one exception, in both modes: it keeps the currency you pinned it to, and the toggle does not move it.