Hello to anyone who works on Wordpress I have the following question: I have more than one article (post) how to make each article its own color or between unit and unit?
I have more than one article (post) how to make each article its own color or between unit and unit?
Asked
Active
Viewed 26 times
1 Answers
0
put this function (https://stackoverflow.com/a/9901154/7224402) into functions.php:
function rand_color() {
return sprintf('#%06X', mt_rand(0, 0xFFFFFF));
}
and then use it in your template:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
$color = rand_color();
?>
// Code for rendering the post.
// Style with $color where needed.
<?php endwhile; ?>

Dmitry
- 347
- 1
- 9
-
this error Parse error: syntax error, unexpected '}', expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) in C:\xampp\htdocs\wp\wp-content\themes\brs\kareem\Homepage\home-form77.php on line 188 – sadiq Aug 27 '18 at 23:20