JReviews logo
Guides My site
← All guides Community guide

Create an affiliate call to action with field shortcodes

g
Thread started by godweb. Contributors godweb.
Thread started
Last updated

What you’ll achieve

Show one persistent event offer banner using each event’s artist, price, booking link, and slogan.

My site

Platform
JReviews version

Show one offer banner on all event detail pages using each listing's artist name, price, affiliate booking link, and slogan. The same banner can stay visible at the bottom of the screen while visitors scroll, so you can reuse one banner for every event.

Add the offer fields and choose where to display the banner

Create or retain an Events listing type and a category assigned to that type. In Setup → Field Groups Manager, create a listing field group named Ticket offer, or reuse an existing listing group. In Setup → Custom Fields Manager, create these fields with Location set to Listing and Field Group set to Ticket offer:

Label Field name Type Example event input
Artist jr_nameartist Text The Lanterns
Price jr_price Decimal 29.95
Booking link jr_bookinglink Website https://tickets.example.com/lanterns?ref=YOUR-ID
Ticket slogan jr_ticketslogan Text Reserve your seat

Replace the example booking URL with the full https:// affiliate URL issued by your ticket provider. Replace YOUR-ID with the affiliate identifier from that provider, or use its complete issued link. Do not publish the example destination.

In Setup → Listing Types Manager, associate Ticket offer with Events. Keep all four fields active, required, publicly readable, and writable by event editors, with no field or group dependencies. Include them in applicable PaidListings plans if used. Event editors fill these values when they create or edit an event. The shortcodes read the saved values and do not supply them automatically.

For jr_price, enter the amount without a symbol or thousands separator. Set Number of decimals to 2, leave Currency format off, and set Output Format to £{fieldtext}. The input 29.95 then displays as £29.95. This example uses pounds sterling. Change the symbol to match your real ticket currency.

For jr_bookinglink, set Output Format to <a href="{fieldtext}" rel="sponsored nofollow">Book now</a>, adapting link attributes to your affiliate program. Keep the normal {fieldtext} output on the artist and slogan fields. Hide all four field titles for this example. Keep the fields publicly readable so the shortcodes can show them.

Save an event with the inputs above and a second event with a different artist, price, booking URL, and slogan. The first banner must show The Lanterns, £29.95, a Book now link to that event's affiliate URL, and Reserve your seat. The second must show its own saved values.

Joomla. Create and publish one Custom module in a template position available on your event detail pages. Enter the banner markup below in HTML source mode. Enable the JReviews Shortcodes system plugin. If its Run only in selected Modules option is enabled, include this module. Check that its menu and component exclusions do not exclude your event pages. Assign the module to the event detail pages and turn off module caching so one event's offer is not reused for another event.

WordPress. In Appearance → Widgets, add a Group block to a widget area shown on event detail pages. Give the group the additional CSS class ticket-offer. Add one Shortcode block for each of the four field shortcodes below, in the same order. Use a footer widget area that renders after the main page content. Apply the event-only widget rule below. Exclude this dynamic widget from any widget cache that reuses its output across listings.

Show the WordPress banner only on event details

Keep the Group block in the theme's widget area. Record its saved widget ID with the administrator inventory in Keep city content in the CMS sidebar. The ID looks like block-9. The ID belongs to the whole Group, so its four Shortcode blocks stay together.

Find the ID of your Events listing type in JReviews. Create wp-content/mu-plugins/events-sidebar.php with the code below. Create the folder if needed. Replace block-9 with your Group's widget ID, and replace 8 with the Events listing-type ID. WordPress loads this file without an activation step.

<?php
/**
 * Plugin Name: Events sidebar
 */

defined('ABSPATH') || exit;

add_filter('widget_display_callback', static function ($instance, $widget, array $args) {
    $widgetId = 'block-9';
    $eventListingTypeId = 8;

    if (is_admin() || $instance === false || $widget->id !== $widgetId) {
        return $instance;
    }

    if (is_404() || is_search() || !is_singular('post')) {
        return false;
    }

    $endpoint = trim((string) get_query_var('url'), '/');

    if (in_array($endpoint, ['listing-edit', 'upload', 'photos', 'videos', 'rss', 'discussions'], true)) {
        return false;
    }

    $post = get_queried_object();

    if (!$post instanceof WP_Post || $post->post_status !== 'publish' || post_password_required($post)) {
        return false;
    }

    global $wpdb;
    $types = $wpdb->get_col($wpdb->prepare(
        "SELECT DISTINCT COALESCE(c.criteriaid, 0)
        FROM {$wpdb->term_relationships} AS r
        INNER JOIN {$wpdb->term_taxonomy} AS t ON t.term_taxonomy_id = r.term_taxonomy_id
        INNER JOIN {$wpdb->prefix}jreviews_content AS f ON f.contentid = r.object_id
        LEFT JOIN {$wpdb->prefix}jreviews_categories AS c ON c.id = t.term_id AND c.`option` = 'com_content'
        WHERE r.object_id = %d AND t.taxonomy = 'category'",
        get_queried_object_id()
    ));

    return count($types) === 1 && (int) $types[0] === $eventListingTypeId ? $instance : false;
}, 10, 3);

The filter shows this widget only on a published event post opened as an individual listing. It checks the post's saved WordPress category relationships and the JReviews listing type assigned to those categories. It does not infer an event from the current menu, a page title, or a listing in a result set. A missing JReviews row, an unconfigured category, or conflicting listing types hides the widget. Keep each listing assigned to its intended JReviews category. Other widgets keep their normal behavior.

This rule supports classic WordPress widgets and blocks saved in a widget area. It does not control a block inserted directly in a Site Editor template. The theme can still reserve an empty sidebar column after the widget disappears.

Exclude this dynamic widget from caches that reuse its rendered content across listings. Clear the page, widget, and CDN caches after installing the rule. As a logged-out visitor, open two event details directly and confirm that each banner shows that event's field values. Open a hotel detail, an event list, and a search page. The event banner must be absent there.

The banner values come from the listing being viewed. Clicking a listing on a list page does not update the banner in place.

JReviews 6 Early Access

Assemble the banner from listing fields

Enable Shortcodes and Listing Detail Page independently in Early Access. Each field shortcode supplies its own field HTML. Paste the example with each shortcode inside its own <div>:

<section class="ticket-offer">
  <div>[jreviews type="field" name="jr_nameartist"]</div>
  <div>[jreviews type="field" name="jr_price"]</div>
  <div>[jreviews type="field" name="jr_bookinglink"]</div>
  <div>[jreviews type="field" name="jr_ticketslogan"]</div>
</section>

Configure each field's Show title option for the labels you want. Do not wrap a complete field block inside an inline heading or paragraph. Use the module or widget placement above, where JReviews has already loaded the event. Placing the banner earlier in a custom page template can leave it without an event to read.

JReviews 5 and v6 Legacy

Assemble the UIkit banner

This banner example uses UIkit styles. Use it where your template loads UIkit, or use the framework-independent banner markup below it:

<section class="ticket-offer">
<div class="uk-grid">
    <div class="uk-width-medium-1-2 align-right"><br><h4>Tickets [jreviews type="field" name="jr_nameartist"] From [jreviews type="field" name="jr_price"]</h4> </div>
    <div class="uk-width-medium-1-2 align-left">[jreviews type="field" name="jr_bookinglink"]
<br>    [jreviews type="field" name="jr_ticketslogan"]</div>
</div>
</section>

For a template without UIkit, use this banner instead:

<section class="ticket-offer">
	<div>Tickets [jreviews type="field" name="jr_nameartist"]</div>
	<div>From [jreviews type="field" name="jr_price"]</div>
	<div>[jreviews type="field" name="jr_bookinglink"]</div>
	<div>[jreviews type="field" name="jr_ticketslogan"]</div>
</section>

Use the Website-field shortcode as shown. It already produces the complete Book now link; do not put it inside another <a href="..."> link. Set the destination and link text in the Website field, then use your template styles to change its appearance.

Keep the banner visible while visitors scroll

To pin the banner to the bottom of the screen, add the CSS below.

For a WordPress Group block, use the ticket-offer class on the Group itself. Do not paste the outer <section> tags into each Shortcode block.

Joomla. Save the CSS in templates/jreviews_overrides/resources/css/custom.css.

WordPress. Save the CSS in jreviews_overrides/resources/css/custom.css.

Use your active custom JReviews theme. Create and select one with the custom-theme setup if needed.

Joomla. Save the CSS in templates/jreviews_overrides/views/themes/{your-theme}/theme_css/custom_styles.css.

WordPress. Save the CSS in jreviews_overrides/views/themes/{your-theme}/theme_css/custom_styles.css.

Replace {your-theme} with your custom theme folder. Clear Cache & File Registry after creating a new stylesheet.

Keep existing CSS rules and append these:

.ticket-offer {
	position: fixed;
	inset-inline: 0;
	bottom: 0;
	z-index: 1000;
	box-sizing: border-box;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: .75rem;
	max-height: 40vh;
	overflow: auto;
	margin: 0;
	padding: 1rem;
	background: #fff;
	color: #222;
	border-top: 1px solid #ccc;
	box-shadow: 0 -2px 8px #0002;
}
body:has(.ticket-offer) {
	padding-bottom: 12rem;
}
.ticket-offer a {
	display: inline-block;
	padding: .5rem .75rem;
	background: #a52222;
	color: #fff;
	text-decoration: none;
}
.ticket-offer a:focus-visible {
	outline: 3px solid #222;
	outline-offset: 3px;
}

Adjust the colors to your site. Increase the page's bottom padding if the banner covers the last page content at a narrow width or larger text size. Check the position against cookie notices, chat controls, and your mobile navigation. The banner should remain reachable by keyboard and leave the page content readable.

You can use your template's persistent-banner feature instead of this CSS. Do not enable two positioning methods for the same banner.

Test more than one listing

Check listings with different artists, prices, slogans, and destinations. Confirm that shortcodes execute, labels are correct, and the booking link reaches the intended destination. Scroll both pages and confirm that the banner stays at the bottom and changes to the current event's values. Check mobile widths, larger text, keyboard access, and the final page content below the banner.

Learn more