WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Change color of current menu item (7 posts)

  1. Shr.Khr
    Member
    Posted 1 year ago #

    I am experimenting with a theme for WP 3.5 which can be found here.

    For hours now I have been trying to change the color of the current menu item, however my efforts have been fruitless.

    So, I was hoping that someone here can help me.

    This is what I am trying to achieve:

    When I am on the 'Home' page, I want its menu text color to change to blue, while the others will remain black.

    When I am on the 'Sample Page' page, I want its menu text to turn blue while the others will remain black.

    I can see in the style.css file that there is a 'current-menu-item' rule; but I am unable to use it.

    Can someone please tell me what CSS to use here.

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    Have you tried this;

    .current_page_item a {
     color: #08c;
    }

    You shouldn't be editing the theme's files if that's what you're doing. Are you?

  3. Shr.Khr
    Member
    Posted 1 year ago #

    Hi Andrew
    I am actually creating a child theme.

    And unfortunately, the style you mentioned above does not work.

  4. Andrew
    Forum Moderator
    Posted 1 year ago #

    Where did you add it? Unless the change is visible on the website, I can't debug it.

  5. Shr.Khr
    Member
    Posted 1 year ago #

    Please check now. It should be visible.

  6. Andrew
    Forum Moderator
    Posted 1 year ago #

    The issue here is that another stylesheet is overriding your CSS changes.

    Add !important to the end of your style,
    E.g;

    .current_page_item a {
     color: #08c !important;
    }
  7. Shr.Khr
    Member
    Posted 1 year ago #

    Top man!
    It works! Thanks!

    So, I have changed the status of this topic to resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic