Problem: I would like to use a Types field shortcode to display the value of a custom field, but I would like to limit the number of characters shown.
Solution: If the field holds HTML (like a WYSIWYG field, for example) then this is not a trivial task, and it would require a significant amount of custom code. However, if the field only holds plain text (like a single line or multi line text field), then you can add the following code to your child theme's functions.php file:
function trim_string_func($atts, $content='') { $a = shortcode_atts( array( 'start' => 0, 'length' => 0, 'string' => '' ), $atts ); $string = $a['string']; $start = $a['start']; $length = $a['length']; return substr($string, $start, $length); }
Then use it like this:
[trim_string string="[types field='coach-holiday-description'][/types]" start="0" length="4"][/trim_string]
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 1 Antwort, has 2 Stimmen.
Last updated by Christian Cox vor 6 Jahre.
Assisted by: Christian Cox.