Created
October 3, 2016 11:39
-
-
Save thesadoo/4774d3817c3dbf80c09cc6bcd879ff1d to your computer and use it in GitHub Desktop.
SpannyTitle: Space separated post titles (separated into numbered span tags)
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 | |
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