Skip to content

Instantly share code, notes, and snippets.

@thesadoo
Created October 3, 2016 11:39
Show Gist options
  • Save thesadoo/4774d3817c3dbf80c09cc6bcd879ff1d to your computer and use it in GitHub Desktop.
Save thesadoo/4774d3817c3dbf80c09cc6bcd879ff1d to your computer and use it in GitHub Desktop.
SpannyTitle: Space separated post titles (separated into numbered span tags)
<?php
public function SpannyTitle( $id = null, $return = true){
$pid = ($id) ? $id : get_the_ID();
$title = get_the_title($pid);
$title = explode(' ', $title);
foreach( $title as $titlenum => $titletext ){
$titlenew .= '<span class="title-num-' . ($titlenum + 1) . '">' . $titletext . ' </span>';
}
if( $return ){
return $titlenew;
} else {
echo $titlenew;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment