Hi, I’m Dana, and I build WordPress membership sites. One of my go-to tools for gamifying these sites is GamiPress—it’s incredibly versatile for rewarding users with points, achievements, and badges.
Today, I want to share a quick but powerful trick that helps streamline how you use GamiPress shortcodes, especially when using GamiPress buttons to award badges or rewards. If you’ve ever felt overwhelmed by long shortcode formats or found it tedious to update them individually, this post is for you.
The Problem: Long, Repetitive Shortcodes
Let’s say you’re using the GamiPress button functionality to reward users. Depending on your setup, you might end up with a shortcode that looks something like this:
[gamipress_earn_award_button award_id="123" label="Collect Your Badge"]
This works perfectly fine—but when you have multiple posts or buttons, managing each shortcode with hardcoded values can quickly become a hassle. Updating button text, IDs, or other parameters requires editing each instance manually.
The Solution: Use Custom Fields to Store the Button ID
To simplify this, I created a custom field that stores the button ID (which is the unique identifier for each GamiPress reward). Here’s how I set it up:
- Create a custom field (using JetEngine or ACF) and assign it to the specific post type where you need the button.
- Label this field something like “Button ID” so it’s clear what it’s used for.
- When you create or edit a post, you simply input the GamiPress award ID into this field.
Dynamically Display the Button in Your Template
Next, you’ll want to dynamically display the GamiPress button using the value from the custom field. In this example, I used JetEngine to pull in the custom field data and wrap it inside the GamiPress shortcode.
Here’s what I did:
- In the single post template, I added a Dynamic Field widget at the bottom.
- I configured it to pull the Button ID custom field.
- Then, I wrapped the dynamic field in the GamiPress shortcode using JetEngine’s macros or dynamic tags.
The result:
[gamipress_earn_award_button award_id="%custom_field_button_id%" label="Collect Your Badge"]
Now, whenever you input a new ID into the custom field, the shortcode automatically updates. No need to manually edit the shortcode on every post!
Why This Setup is Better
- Easier to manage: You only need to update the shortcode format in one place—your template. Any changes to button text, delay, or styling apply globally.
- Faster updates: If you want to change “Collect Your Badge” to something like “Claim Your Reward,” just update it once in the template.
- More flexible: You can adjust settings like delay (e.g., a 2-second delay) globally, without editing each shortcode individually.
Of course, there’s nothing wrong with the original method. This is just a more efficient and scalable approach, especially for larger sites with lots of rewards.
Tools & Plugins that used
- GamiPress
- Crocoblock JetEngine