Forums

[resolved] Multiple Backgrounds (switch between them) (3 posts)

  1. ccmovies
    Member
    Posted 1 year ago #

    Hello,

    I am making a wordpress theme and want to display the date of the post on a "sticky note" and I do not want every sticky note to look the same. For example, I would like one to be straight, and the next time I post something, the sticky note is a little crocked. So, it would switch between a couple of "stick note" images I have made. How would I do this?

    Thanks,
    Connor

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    add a random number to the style of the post date div; for instance:
    (as you haven't posted the code that you are using)

    <div class="post-date note-<?php echo rand(1,5); ?>"><?php the_time('Y M d'); ?></div>

    and in style.css:

    .post-date.note-1 { background-image: url(images/sticky-note-1.png); }
    .post-date.note-2 { background-image: url(images/sticky-note-2.png); }
    etc.

    http://php.net/manual/en/function.rand.php

  3. ccmovies
    Member
    Posted 1 year ago #

    Oh that is awesome, thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic