split the content of the_content();
-
Hi,
I want the content before <–more–> tag in one column and the rest in another column (single.php) only.
I don’t want to use plug-ins that you need to edit all the post to get it as I want.
I’ve done following
Added following in functions.php
// split content at the more tag and return an array function split_content() { global $more; $more = true; $content = preg_split('/<span id="more-\d+"><\/span>/i', get_the_content('more')); for($c = 0, $csize = count($content); $c < $csize; $c++) { $content[$c] = apply_filters('the_content', $content[$c]); } return $content; }
and added following to single.php
<?php // original content display // the_content(); // split content into array $content = split_content(); // output first content section in column1 echo '<div id="column1">', array_shift($content), '</div>'; // output remaining content sections in column2 echo '<div id="column2">', implode($content), '</div>'; ?>
when viewing a post, it just get the output of this :
echo ‘<div id=”column1″>’, array_shift($content), ‘</div>’;
No content from echo ‘<div id=”column2″>’, implode($content)
I’ve tried plug-ins with similar features and these as the same output as I mention above. (get all the content before <–more–>, but not after the <–more–>).
So I hope someone has a suggestion to solve my little dilemma or know about a plug-ins that do the same.
Thanks in advance ??
- The topic ‘split the content of the_content();’ is closed to new replies.