Home › Forums › Front-end Issues › Loop Category with custom text field and add current-cat class › Reply To: Loop Category with custom text field and add current-cat class
Thank you very much @hube2, the solution seems pretty easy, but I have a problem: in this way each div “item” has the name of each category and I predict every category name in my CSS.
How instead I could transform your $ cat_class into a generic variable in the sense: I take the name of the current category (the one I’m seeing) and I associate it with a generic class (example: current-class) so in my CSS I could say: if the class is current-class then this is the rule.
My CSS Code:
.category-carousel .cat-icon{
border:2px solid #0057ff;
display:inline-block;
height:50px;
width:50px;
line-height:46px;
border-radius:100%;
-webkit-border-radius:100%;
-moz-border-radius:100%;
-webkit-box-shadow: 1px 1px 10px -6px rgba(0,0,0,0.3);
-moz-box-shadow: 1px 1px 10px -6px rgba(0,0,0,0.3);
box-shadow: 1px 1px 10px -6px rgba(0,0,0,0.3);}
/*Current Category*/
.category-carousel .cat-icon.category-fotografia{
border:2px solid #000;}
Thanks a lot for the answer.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc
— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.