• alamba78

    (@alamba78)


    [In reference to https://www.ads-software.com/support/3/16724 ]
    Ok, so I have been thinking for a while now how to style the first post differently from the others by keeping track of a counter variable. And I tried implementing a counter and such. But, my new problem lies in the foreach loop:
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    Even with a counter, how am I supposed to differentiate the first post from the rest uniquely so my 2nd loop (or run through) after incrementing the counter, only goes through the remaining posts, excluding the first post. My problem is (a) with the foreach loop and (b) uniquely separating the first post from all others.
    I understand this is more of a programming/logic question, than a how-to regarding wordpress. Please bare with me here. I think this would be a neat feature out of the box for future releases. So, to get this hacked for the current version would be really awesome. I guess somehow I would need to run a for (not foreach) loop for the first post, and then run a foreach loop for the remaining posts. But, again how would I differentiate the first post from the rest so that the 2nd loop excludes the first post. Somehow I’m going to have to possibly incorporate the_ID function. Right now I’m just thinking aloud and writing my thoughts. Any advice would be welcome. Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Anonymous

    Please bare with me here.

    Weeee! Let’s get naked! ??
    This has been done many ways with hacks and plugins. Perhaps a search on this site will lead you to a solution that works for you.

    Thread Starter alamba78

    (@alamba78)

    For anyone else interested in this, I think I finally found a post dealing with this very issue at:
    https://www.ads-software.com/support/3/7335

    davidchait

    (@davidchait)

    We went through a whole discussion at one point dealing with per-category CSS, as well as alternating styles (odd-even coloring).
    The same applies to first-post. The best way is to wrap the first post in an extra DIV of a class you specify, or maybe use IDs on each class=post div and specially style ID=1.
    -d

    Thread Starter alamba78

    (@alamba78)

    I think I was smokin something when i posted that prevoius link. That doesn’t have anything to do with what i want. Here is a better link:
    https://www.ads-software.com/support/3/13071
    dividchait, is there any code example showing what you’re talking about. It would be neat to see how someone else has implemented this request. Thanks. I will be fully going through this link I posted now, hopefully I haven’t asked a question that will be answered in there. Thanks for the input.

    Thread Starter alamba78

    (@alamba78)

    Hey davidchait, when you say wrap an extra div around my post, did you mean in the admin->post interface where the text for the post goes? Woah, if that’s possible, it would save me so much headache. I’m trying to think of ways to hack the foreach loop in index.php . Holy crap, I gotta try making life easier on myself. Lemme go see if it’s possible or if i just made a jackas$ out of myself. LOL.

    Thread Starter alamba78

    (@alamba78)

    Ahh, that method I just mentioned only styles the text of the post. It doens’t style the title, the meta, and the feedback area of a post.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘first post styled different from rest’ is closed to new replies.