Background color based on category
-
I’m trying to add a background color to a div based on the category the post belongs in using the code below
echo ' <div class= "thumb"><a href="' . get_permalink() . '">' . get_the_post_thumbnail() . '</a></div> <div class= "catcolor"> if ( in_category( '6' ) ) { echo '<div class= "thumbcat1">'; } elseif ( in_category( '7' ) ) { echo '<div class= "thumbcat1">'; } elseif ( in_category( '8' ) ) { echo '<div class= "thumbcat2">'; } elseif ( in_category( '9' ) ) { echo '<div class= "thumbcat2">'; } elseif ( in_category( '10' ) ) { echo '<div class= "thumbcat3">'; } elseif ( in_category( '11' ) ) { echo '<div class= "thumbcat3">'; } elseif ( is_category() ) { echo 'background-color: #000'; } </div> <div class= "title"><h3><a href="' . get_permalink() .'">' . get_the_title() . '</a></h3> </div>';
but it’s not working… I keep getting the error
Parse error: syntax error, unexpected T_LNUMBER, expecting ‘,’ or ‘;’ in /home/soulofan/public_html/wplearn/wp-content/themes/Scharc/archive2.php on line 24
what am I doing wrong?
I’m not a php coder and this is the first theme I am building.
Here’s the link
I appreciate the help, thanks!
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Background color based on category’ is closed to new replies.