Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7590755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:29:01+00:00 2026-05-30T20:29:01+00:00

I am trying to apply a special CSS to my WordPress navigation based on

  • 0

I am trying to apply a special CSS to my WordPress navigation based on a post type the user is currently on.

I have gone as far as identifying the post type and applying the css to the menu. However, my problem is that it applies the CSS to the entire menu, and i need it to apply the css change to a specific menu item.

The following is the code in my functions.php file:

add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class($classes, $item){

    if ( 'portfolio' == get_post_type() ){

             $classes[] = 'current-menu-item';

     }

     return $classes;

}

It is applying the CSS correctly, but how can i get it to apply the CSS only to my menu item named ‘Work’?

Any help appreciated! Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:29:03+00:00Added an answer on May 30, 2026 at 8:29 pm

    Take advantage of the CSS classes field on your wordpress menu.
    If you are using the wordpress generated menu set-up, click on screen options in the top right corner and check the CSS classes box.

    Open up any of the menu items and you will see a field to add a CSS class now.

    Then you can add a class to each menu item (maybe treat it like an ID in that you are using it to target a specific button)

    That special class for that individual button may give you the hook you are looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to apply css on my html.dropdownlist with a regular html select
I am trying to apply css on the first A element inside .Outer, .Outer
I am trying to apply COUNT() in a query and I have it working
I'm trying to find a way to apply a css class to the first
While trying to apply policy-based design, I got stuck on this one (simplified): template
i have been trying to apply the Gridview Tutorial but i'm stuck in an
I am trying to apply the custom grammar for speech recognition. I have found
I am trying to apply css for my table as show in sample 9.Table
I have made a lot of jQuery special events, and now I am trying
Im trying to apply different background color to even and odd items in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.