Skip to:

highlight first post

  • 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)
  • 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

    i’ll give this a shot kawauso.

    thanks for now :)

    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:

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

    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(); ?>">
    <td class="typo">
    <?php post_text(); ?><div class="link"><?php post_edit_link(); ?><?php post_delete_link(); ?><?php post_ip_link(); ?></div>
    <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() ); ?>


    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.

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

    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)

    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

    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