• Hello,

    I’ve been searching for a method to split the post’s content automatically, in order to control by html the page layout, in two columns side by side i.e.

    I’ve found a very useful thread, and, using the first formula there provided, I’ve realized the last post’s word disappears, don’t know why.

    Here I’m going to reproduce the code we can find in the topic. I quote:

    “Add the following just after the start of The Loop in your Page template:

    <?php
    $numchars = strlen($post->post_content);
    $content = wordwrap($post->post_content, $numchars/2, "{{break}}");
    $content = split("{{break}}", $content);
    ?>

    Then (again in your template) within each column, you want to replace the_content() template tag with these:

    First column:
    <?php echo apply_filters('the_content', $content[0]); ?>

    Second column:
    <?php echo apply_filters('the_content', $content[1]); ?>

    Can anybody confirm the code works well ?
    For me, as said, the last word just get lost.
    Also, I’ve had some problems with a post containing some hyperlinks, and which seemed to break the entire layout (once more, no idea).

    If someone try it out, thanks for reporting any result.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Dunkkan,

    I’m considering starting a blog and using WordPress. Your description of the two column functionality is exactly what I’m looking to do. Did you ever resolve the missing word? Once I get it going, I will try your code out and let you know how it worked.

    Thanks,
    Jcarpent

    Dunkkan, thanks for the info. I’m trying to do something similar, and this code is moving in the right direction for what i’m trying to achieve

    Mike

    array/string lengths can be funny… without getting too technical, I’ll just say change your code to the following:

    <?php
    $numchars = strlen($post->post_content);
    $content = wordwrap($post->post_content, $numchars/2+2, "{{break}}");
    $content = split("{{break}}", $content);
    ?>

    Hey this is just what I was looking for.

    I’ve been dreaming about making a horizontal theme that scrolls sideways when the mouse scrolls. Mootools can do this.

    Is it possible to have an infinite number of columns, so that the post can just split itself into columns (that are the height of the browser) that just continue to the right – horizontally.

    I know it’s a long shot, but if anyone knows that would be great.

    This is exactly what I was looking for as well. A HUGE help.. Could someone give me a rundown of how the math for the wordwrap is working? I have some images in these pages that are somewhat consistently placed and therefore the first column is significantly larger than the second.

    Any help on this would be greatly appreciated.

    Thanks,
    Pete

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘two columns content layout’ is closed to new replies.