Back to Tips & Tricks

How to Create a Responsive Trim Text Callback in JetEngine with Device-Specific Control and Optional Title Links

Published on 30 July 2025

If you're building dynamic websites with JetEngine, you already know how powerful the Dynamic Field widget is. But what if you want to trim text differently for desktop, tablet, and mobile, and maybe even make the trimmed text clickable? That’s where this custom callback comes in.

In this guide, you'll learn how to:

    • Trim text dynamically based on device type (desktop, tablet, mobile)

    • Add clickable title/text links

    • Let users control trim length per device

    • Use this as a reusable PHP snippet in your WordPress site

Let’s dive in.

 

🧩 What This Custom Callback Does

This custom trim text callback extends JetEngine’s Dynamic Field widget by adding:

Responsive trimming: Set a different word limit for desktop, tablet, and mobile.

Optional clickable titles: Turn the trimmed text into a link to the current post.

Open in a new tab: You can choose whether the link opens in a new tab or not.

Clean design: Text appears smoothly across devices with no style conflicts.


🧑‍💻 How to Add the Snippet to WordPress

You can use a plugin like Code Snippets or WPCode to paste the following code and activate it. It’s completely safe and doesn’t require modifying your theme files.

📎 PHP Snippet to Add:

How to Create a Responsive Trim Text Callback in JetEngine with Device-Specific Control and Optional Title Links - BoostMyCroco