Created
November 25, 2019 23:44
-
-
Save djrmom/e3527ac45619e46a32c0785510082242 to your computer and use it in GitHub Desktop.
facetwp shorten text output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** shorten text to a specified length and add ellipses | |
** may need adjusting if you need to support multi-byte characers | |
** https://www.php.net/manual/en/function.mb-substr.php | |
** https://www.php.net/manual/en/function.mb-strlen.php | |
**/ | |
add_filter( 'facetwp_builder_item_value', function( $value, $item ) { | |
if ( 'el-ymud8n' == $item['settings']['name'] ) { | |
if ( strlen( $value ) > 50 ) | |
$value = substr( $value, 0, 50 ) . " &hellip"; | |
} | |
return $value; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment