How to add class to autogenerated menu items

Hi Gurus,

I'm using CoursePress Pro and it automatically adds a couple of menu items, which is great.

Is it possible to add a classname to them? I'm using a plugin which adds some cool CSS and all I need to do is add a custom classname to apply the CSS. In the case of the menu items, I'm not sure where I would do that.

Thanks kindly,

  • Adam Czajczyk
    • Support Gorilla

    Hello Emilio,

    I hope you're well today and thank you for your question!

    These menu items already have classes assigned automatically. Their names start with "menu-item-cp-" so it's e.g. "menu-item-cp-courses" for "Courses" menu item. That can't be changed via plugin's settings. There's a simple workaround though:

    1. Go to the "CoursePress -> Settings -> General" and disable the "Display Menu Items" option so plugin will no longer add these items to the menu automatically.

    2. Go to the "Appearance -> Menus" page

    3. Expand "Screen Options" tab at the top of the screen and make sure that "CoursePress Pro" checkbox is marked

    4. Now an entire "CoursePress" section should be available for you where you can drag necessary links from to your menu and there you can add your custom class name. You could also use a "Custom Links" option instead to link to selected CoursePress sections.

    Best regards,

  • emilio_gagliardi
    • The Incredible Code Injector

    Hi Adam,

    Thank you very much for the above procedure. It almost solves my issues.

    1) Is there a way to add a "Logout" menu item only when a user is logged in? The nice thing about the automenu feature of CoursePress was handling that feature. When I look at the CoursePress Pro section under Menus, there are no Account or Logout options there, just the courses.

    Any guidance is greatly appreciated.

  • Dimitris
    • Support Star

    Hey there,

    this plugin should use some simple filters, redirects, and conditionals, nothing more basically, so you won't have any issues. I even tested that before proposing it, so I could be sure that's still working properly. :slight_smile:


  • emilio_gagliardi
    • The Incredible Code Injector

    Hi Dimitris,

    Thank you for being so thorough! I found another solution that I am happy to share for your consideration.

    The first plugin makes it easy to add conditional login/logout to menu, but it doesn't allow you to create menu items to the Student Dashboard or Student Courses. In order to create those menu items (with custom classes) and have them only show up after the user has logged in, you need the second plugin, which allows you to apply conditional logic to menu items.

    I now have the solution I was hoping for. Thank you kindly for getting me on the right path!


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.