Created
July 10, 2017 22:38
-
-
Save rafaehlers/369332518f68c9861680c10386b6b340 to your computer and use it in GitHub Desktop.
Strip the first word only of a string
This file contains hidden or 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
add_shortcode( 'gv_wordstrip', 'gv_wordstrip' ); | |
function gv_wordstrip( $atts ) { | |
global $gravityview_view; | |
extract($gravityview_view->field_data); // create a $entry variable with current entry data array | |
extract( shortcode_atts( | |
array( | |
'field_id' => '', | |
), $atts ) | |
); | |
$word = $entry[$field_id]; | |
if (empty($word)) { | |
return 'Error: No field ID specified.'; | |
}else{ | |
$firstword = substr($word, 0,1); | |
} | |
return $firstword; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment