• Heyo!
    First — WP rocks!!! Thank you guys for it! Love it!
    Now the question — I wanna apply different style for the latest entry , so that other post will have like default style but the very latest uses different style.. Hope you know what I mean.. I know I should use if $count==0 {latest_style} else{regular_style}, etc.., but Im stupid enough to make it work ;( Can somebody, please, help me with this?
    I searched for the entries for this kinda problem, but couldnt find answer for this one…
    I would really appriciate if you could help me.. ??
    Thaks a lot.
    Keep up the good work ??
    Villu

Viewing 12 replies - 1 through 12 (of 12 total)
  • I don’t know of a WP function that can do this but here’s an idea from someone who just learned a few PHP commands and now fancies himself a hacker ??
    3 steps:
    1. Set up a PHP variable in your index.php that keeps track of the number of posts displayed on the page.
    2. Again in index.php, change the line that says <div class="post"> to a PHP statement that echoes <div class="post"> if the count is at the initial value, and <div class="firstpost">
    3. in your stylesheet, apply different styles to the classes “post” and “firstpost”
    Does that make sense? I know it needs a bit of PHP…

    Ah, problem… this does not apply the “firstpost” style to the latest post, but to the first post displayed on the page. Which might not be the latest if you’re displaying a specific category, search results etc. So it would only really do what you want for the front page.

    Thread Starter villu

    (@villu)

    Oh… It’s easy … Thanks a lot! I try to put something together.
    Thanks again.

    If you get it to work, I’d love to see the code ??

    Thread Starter villu

    (@villu)

    OK… I will let you know ??

    A note on your CSS above – underscores aren’t recommended in CSS selectors (strange but true) so you need to rename “latest_post” for maximum compatibility.
    see https://devedge.netscape.com/viewsource/2001/css-underscores/
    J.

    Thread Starter villu

    (@villu)

    OH.. I had no idea.. Thanks
    Villu

    Wayhey, you got it working! It still highlights the first post on any page even if that’s not the last one posted, but looks good anyway. I also like your JavaScript expanding submenus!

    how could this be applied to specific categories?
    so that if a post is from category B, for example, then the text-color would be blue.. if it comes from category Y, then the border would be yellow. .. (i wonder that there might be complications if the post is given more than one/conflicting category labels.. but perhaps it would just take the style assigned to the first of the categories? or the last?)
    or something like this?

    You dont suppose eric here who says he has just learned php is *the* eric do you? Anybody?

    Root, you are speaking in riddles. Excuse my presumption, but just in case you mean Meyer or Raymond, I’m very flattered indeed, but definitely not guilty. I am not this guy either.
    If and when I have my own blog instead of just doing them for other people, I’ll post a link.

    Excuse my presumption, but just in case you mean Meyer or Raymond, I’d be very flattered indeed, but definitely not guilty. I am not this guy either.
    But you can call me The Eric, of course!
    If and when I have my own blog instead of just doing them for other people, I’ll post a link.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Different style for the latest post’ is closed to new replies.