Forums

Getting the ID of the post in the loop (2 posts)

  1. aronevans
    Member
    Posted 4 months ago #

    Hi there,

    I'm in the middle of coding my own WordPress theme from scratch and would appreciate if someone could shed some light on a matter that's confusing me a bit.

    I'm just coding one of my category pages and working with the loop. At the minute I have a stylesheet set up, which assigns a different style to each blog post within this category. They're called #blog-block-1, #blog-block-2, #blog-block-3 etc, up to 30 - each has a different style in the stylesheet.

    I need to somehow get the loop to reference to these styles, depending on the position of the entry in the loop. So the most recent would be #blog-block-1 and the last #blog-block-30

    Is this the post_id function, or does that refer specifically to the ID of the blog post in the system

    If anyone could shed some light on the matter it would be fully appreciated!

    Thank you :)

  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 months ago #

    It refers specifically to the ID of the blog post in the database The easiest approach would be to just set up a simple counter variable that is incremented on every Loop pass.

Reply

You must log in to post.

About this Topic

Tags