• The Palette option lets you define a grab bag of colors that Randomize CSS will pick from at random. That is, the colors themselves aren’t random, but which one it picks is.

    However, after an hour of digging through code and pulling my hair out, I was still totally baffled about how to get it to work. Well, I had my Eureka moment at last, and I’ll spare you guys the same effort and explain it here…

    In your template, you’ll need to define what your palettes are. That definition looks something like this:

    def PALETTE001={C1:#000,C2:#24890d,C3:#0074a2,C4:#2ea2cc,C5:#fff}

    That code basically says to WordPress “The first palette is made up of five different colors, and here they are. Color 1 is #000, color 2 is #24890d…” etc. You’ll want to add a few more of these:

    def PALETTE002={C1:#e5e5e5,C2:#999,C3;#d64e07,C4:#04a4cc,C5:#333}
    def PALETTE003={C1:#096484,C2:#4796b3,C3:#52accc,C4:#74B6CE,C5:#eee}
    def PALETTE004={C1:#46403c,C2:#59524c,C3:#c7a589,C4:#9ea476,C5:#eee}

    Then, in your template, you’ll call the palette like this:

    .widget a{color:[PALETTE.C1]}

    But here’s the part I kept tripping over, and it so totally bizarre I laughed out loud when I figured it out: the plugin doesn’t pull the colors from one palette! Instead, it pulls them from every C1 in every defined palette.

    So, in my example above, the class “widget” would be assigned a random color from the four palettes’ C1 entries: either #000, #e5e5e5, #096484, or #46403c. Another way of saying it is that it pulls the colors from vertical columns instead of horizontal rows.

    If you want your widget to cycle between 15 different colors, then you’ll need to create 15 different palettes:

    def PALETTE001={C1:#your_first_color_goes_here}
    def PALETTE002={C1:#your_second_color_goes_here}
    def PALETTE003={C1:#your_third_color_goes_here}

    Etc, until you hit fifteen. And if, elsewhere on your site, you have another element you want to have change color randomly, you’d start a C2 column in those palettes.

    Like I said, it’s pretty unintuitive, but it’s easy once you figure it out. I hope this saves someone a little time in the future. (And Flocsy, I love the plugin, thanks for releasing it to the community!)

    https://wordpress.org/plugins/randomize-css/

  • The topic ‘How To Use The Palette Option’ is closed to new replies.