Forums

Join
bbPress Support ForumsThemesSeparating the first post of each topic

Info

Separating the first post of each topic

  1. Hi!

    I want to separe the first post of each topic from the loop ol list but I can find out how. In topic.php here;

    <ol id="thread" start="<?php echo $list_start; ?>">
    
        <?php foreach ($posts as $bb_post) : $del_class = post_del_class(); ?>
    
        	<li id="post-<?php post_id(); ?>"<?php alt_class('post', $del_class); ?>>
    
                <?php bb_post_template(); ?>
    
        	</li>
    
        <?php endforeach; ?>
    
    </ol>

    I'd like to change the loop so I can insert a h6 header after the first post and threads look like this;

    h6 -> "Topic title"

    First post

    h6 -> "Responses; "

    ol li -> rest of the posts

    Is it possible to build a custom loop that only shows the first post and then insert a second loop for the rest of the post with an offset of 1?

  2. Untested code below:

    <?php $bb_post = $posts[0]; unset($posts[0]);   $del_class = post_del_class();?>
    <div id="post-<?php post_id(); ?>"<?php alt_class('post', $del_class); ?>>
           <?php bb_post_template(); ?>
    </div>
    <h6>Responses</h6>
    <ol id="thread" start="<?php echo $list_start; ?>">
        <?php foreach ($posts as $bb_post) : $del_class = post_del_class(); ?>
        	<li id="post-<?php post_id(); ?>"<?php alt_class('post', $del_class); ?>>
                <?php bb_post_template(); ?>
        	</li>
        <?php endforeach; ?>
    </ol>
  3. Hi nightgunner!

    Thanks for the code :) It works great.

  4. AWESOME!!!!!!! That's all I can say.

  5. You must log in to post.