WordPress.org

Ready to get started?Download WordPress

Forums

Using body_class and reversing paged-n ID (1 post)

  1. withrye
    Member
    Posted 3 years ago #

    I am trying to display a different body background image for every post. Currently, I've set the option to display only one post per page, and using body_class() to assign a unique background image for each post on its own page through CSS:

    .paged-1 { background:url(bg1.jpg); }
    .paged-2 { background:url(bg2.jpg); }
    etc.

    It works! Sort of. The paged IDs are in the reverse order of what I expected. It seems my most recent post/page is re-assigned paged=1. Every post/page then gets its paged ID changed every time I post. This shuffles my background images because all my CSS classes now point to a newer post. I would have to manually update all of them with every new post, which is bad.

    Does anyone know how I can solve this? Thanks in advance for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic