Support » Fixing WordPress » Different first post for each chronically divided post group (i.e Today…)

  • Resolved ggg377


    Hi. Sorry, this is a sloppy title. Couldn’t word it better, unfortunately.

    I’ll start off by posting this explanatory image so it doesn’t get too confusing, because the essence of my problem is quite simple: picture

    Anyway, all my blog posts get divided as either “Today”, “Yesterday” or “the_date”. The dividing produces groups of posts under the title of the division (which is either Today, yesterday or the_date). I want these groups to be separated by borders, in my current solution I have assigned top borders for all the titles (through #post), but this also assigns a top border to the first entry of the group, which I don’t like. How would I remove the top border from the first entries of these categories? There’s also the problem of a single entry. I would love if a single entry didn’t have neither top nor bottom borders.

    The loop:

    I should add that all out of the box solutions are welcome. Thanks in advance for your for your help and effort!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Can you post a link to your site where a page like this exists. Borders are set in the CSS code, so php code isn’t really useful or relevant. Not sure whether it can be easily changed in the CSS code – but looking at the site will help answer that.

    Here’s the link to the page.

    Hey WPyogi, can you please verify you at least saw my link? I’m keeping my page stripped down for the public eye and I would like to have the link taken down at one point. Thanks.

    Alright, it has become apparent to me that this seemingly easy issue won’t be easily solved. Here are a few thoughts I’ve had since I made this thread.

    As it seems to me (I could be very wrong of course), my current code sort of “pseudo-groups” the posts, meaning it just inserts the dates between an otherwise coherent flow of posts. This isn’t essentially “grouping” and separating the first posts out of these categories should be impossible, because there isn’t a way to identify these posts any way through code (at least I think so?). So I thought in order to reach my desired outcome, I would need “Today”, “Yesterday” and “the_date” to all have separate outputs, so I could style each of them differently (these separated outputs would be really useful later on as well).

    I could then hypothetically use the first-child CSS selector to style the first post differently (not sure if this would work). Or I could pinpoint the first post through PHP somehow and stylize it differently through a div.

    Can anyone please comment on these ideas and tell me if they’re heading towards the right direction. These ideas could be completely wrong and misguided for all I know. This is honestly in no way an attempt to bump the thread, these are ideas I legitimately would like to discuss with you, because I’m prepared to undertake the coding part myself now. I just need to know whether it would be possible to have different outputs for today, yesterday and the_date and the general means of doing it (will I need different loops?)

    Thanks for your help, and if you have any ideas on this subject, please consider responding.


    Hey ggg377 – sorry I missed this until just now. I haven’t had a chance to look at it in detail, but yes, both of your ideas are what I would try – if you can add a special CSS class to the h tags for the one where you don’t want to the top border, then you can use that class to set the border to none in the CSS… Or the first or last child CSS might work to do the same thing.



    Forum Moderator

    two changes to your code:

    <?php $w_h = $w_d = $last = 0; ?>


    <div id="post"<?php if( get_the_time('Yz') != $last ) { $last = get_the_time('Yz'); echo ' class="first"'; } ?>>

    and in the css, add:

    #post.first { border-top: none; }

    Hah, I knew alchymyth would have this solved in a flash – was hoping he’s happen along :)!

    WPyogi: Absolutely no problems, I was just scared someone would interpret my attempts of trying to get noticed by you as bumping and ban me.

    alcymyth, that did the trick! Awesome! Just for future reference, that one part in the post div should be ' class="first" ' (with the space inbetween) otherwise it won’t work, but clearly that’s a non-issue. You saved me from hours of empty work 🙂 Thanks again.

    Also, would it be possible to remove the link to my site because it is under development? I think the code should get the point across to everyone who’s interested in a similar solution.



    Forum Moderator

    would it be possible to remove the link to my site because it is under development?

    unfortunately – no.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Different first post for each chronically divided post group (i.e Today…)’ is closed to new replies.