Created
August 20, 2013 20:20
-
-
Save angeliquejw/6286743 to your computer and use it in GitHub Desktop.
Trim custom field in WordPress
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 | |
$trim_length = 25; //desired length of text to display | |
$value_more = '(…)'; // what to add at the end of the trimmed text | |
$custom_field = 'my-custom-field-name'; | |
$value = get_post_meta($post->ID, $custom_field, true); | |
if ($value) { | |
echo wp_trim_words( $value, $trim_length, $value_more); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment