Check if is category page
-
Hello, i have created a menu with the categories, The only think is that i want to change the css of the active category. Until now the code is like this:
<div class="CategoryMenu"> <?php $Awards_id= get_cat_ID('awards'); $Press_id= get_cat_ID('press'); $News_id= get_cat_ID('news'); $Commercial_id= get_cat_ID('commercial'); $args = array( 'orderby' => 'name', 'parent' => 0, 'exclude' => array($Awards_id,$Press_id,$News_id ) ); $categories = get_categories( $args ); foreach ( $categories as $category ) { echo '<a class="CategoryArchive" href="' . get_category_link( $category->term_id ) . '">' . $category->name . '</a><br/>'; } ?> </div>
Here for example the category is commercial, the foreach loop goes through all the categories and creates the link.I tried to make an if statement with is_category() function but it seems it wasnt working.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Check if is category page’ is closed to new replies.