Forums

Splitting the_content so it can be displayed in different rows (1 post)

  1. ggarner6
    Member
    Posted 4 months ago #

    So I am trying to do the following:

    Break up the_content so that a portion can be displayed at the top of the page layout, and then have some photos that are inserted via custom fields, and then I would like the remainder of the_content to be displayed below the images.

    I have been reading over how people do this for breaking up the_content into multiple columns, but have not seen anything on doing it for rows.

    I have been messing around with it for a little bit and dont have anything that works yet.

    Should it be something like this?
    Insert this into functions.php

    <?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 then put this into the sub theme?

    <?php
        $content = split_content();
        // output first content section in column1
        echo '<div id="column1">', array_shift($content), '</div>';
    ?>

    then i would display my images... and then

    // output remaining content sections in column2
        <?php
        echo '<div id="column2">', implode($content), '</div>';
        ?>

Reply

You must log in to post.

About this Topic