Skip to:
Content
Pages
Categories
Search
Top
Bottom

highlight first post

  • @johnnydoe

    Member

    hello,

    is there a way or possibility to highlight or to change the appearance (with css) of every first/initial post?

    thank’s in advance.

Viewing 10 replies - 1 through 10 (of 10 total)
  • @kawauso

    Member

    The ID of the entire first post (including the poster’s details) would depend on your theme’s code, but in Kakumei it’d be div#position-1. If it’s anything else, it’d be under post.php, but you could just use Mozilla Firefox’s DOM Inspector or Google Chrome’s Inspect Element to check the ID on the page anyway.

    Again in the case of Kakumei, the post itself is .threadpost, so you could use something like <style>div#position-1 .threadpost {background-color:#FFFF99;}</style> to change the background colour.

    Hope that’s some help

    @johnnydoe

    Member

    i’ll give this a shot kawauso.

    thanks for now :)

    @johnhiler

    Member

    Are you using 0.9 or 1.0?

    1.0 added some extra tricks to make it easier to style posts based on their position:

    https://bbpress.org/forums/topic/how-to-add-different-style-to-the-first-post

    @johnnydoe

    Member

    i’m using 1.0 johnhiler, thank’s for your link.

    @johnnydoe

    Member

    yay this is somehow all greek to me, were you able to handle those instructions john?

    since i’m not a kakumei user it seems to be a little tricky

    so i’ve got in my topic.php…

    <?php do_action('under_title', ''); ?>
    <?php if ($posts) : ?>
    <?php topic_pages(); ?>
    <?php foreach ($posts as $bb_post) : $del_class = post_del_class(); ?>
    <?php bb_post_template(); ?>
    <?php endforeach; ?>

    <?php topic_pages(); ?>
    <?php endif; ?>

    and in my post.php the following code…

    <table class="content" id="fbg3" cellspacing="0" id="post-<?php post_id(); ?>">
    <tr>
    <td class="typo">
    <?php post_text(); ?><div class="link"><?php post_edit_link(); ?><?php post_delete_link(); ?><?php post_ip_link(); ?></div>
    </td>
    <td class="info">
    <div class="avatar"><?php post_author_avatar(); ?></div>
    <div id="fbg3info">
    <div id="bubble2"></div>
    <a href="<?php bb_option('uri'); ?>profile.php?id=<?php post_author(); ?>"><b><?php post_author(); ?></b></a><br />
    <?php printf( __('%s'), bb_get_post_time() ); ?>
    </div>
    </td>
    </tr>
    </table>

    :/

    @kawauso

    Member

    Blergh. No idea why they’re using the post_id() instead, but okay. Try putting this <?php if (bb_is_first(get_post_id())) : ?> style="background-color:#FFFF99;"<?php endif; ?> after class="typo" (no need for a space). You can change the style to a class or whatever obviously, but I think that should work.

    @johnnydoe

    Member

    eureka, thanks a ton kawuso … just a simple one liner! brilliant!

    @bbisimone

    Member

    I’ve got another question for the topic at hand:

    Is it possible to completely take the first post out of the “loop”? I mean by simple CSS it’s possible to style it differently, which is cool.

    But instead would it no be nice to be able to add other html below the first post (e.g. pagination) and when you are on the second page you still see the first post, with the answers below:

    Page 1

    -First Post/Question

    -Pagination/Other html

    -Rest of the post/Answers 1-20

    Page 2

    -First Post/Question

    -Pagination/Other html

    -Continuation of the Answers (21-41)

    @kawauso

    Member

    Put <?php if (get_post_position() == 1) { continue; } ?> after the foreach ($posts as $bb_post) line in topics.php to stop the first post appearing in the loop.

    To get the first post separately, you could use <?php $bb_post = bb_get_first_post(); bb_post_template(); ?> or <?php $bb_post = bb_get_first_post(); ?> and use the same functions as in post.php in your HTML.

    No idea on modifying the number of posts for the first page though :) probably a plugin for that

    @bbisimone

    Member

    Now once again this works perfectly for me Kawauso, thank you very much!

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar